Skip to content

es_ES isbn13 returns ISBN with an empty registrant segment - #2477

Closed
feiiiiii5 wants to merge 1 commit into
joke2k:masterfrom
feiiiiii5:fix/es-isbn-remove-empty-registrant-rules
Closed

feiiiiii5 wants to merge 1 commit into
joke2k:masterfrom
feiiiiii5:fix/es-isbn-remove-empty-registrant-rules

Conversation

@feiiiiii5

Copy link
Copy Markdown

What does this change

Removes the bogus 978/13 registrant-group rules from the es_ES ISBN provider so Faker("es_ES").isbn13() no longer emits ISBNs with an empty registrant segment.

What was wrong

faker/providers/isbn/es_ES/__init__.py lists four ranges for group "13" with a registrant length of 0 (0100000-5999999, 6050000-6999999, 7350000-8749999, 9000000-9899999). When one of those ranges is drawn, _registrant_publication splits the registrant as the empty string, and ISBN13.format() joins it back as 978-13--<digits>-<check> — one empty hyphen-delimited field in roughly 44% of 2000 seeded draws on master 1879c986 (878/2000), confirmed for both es_ES and es (which inherits it) with 0/2000 for every other locale.

The malformed samples are not parseable ISBN-13: the segment between the group and the publication is empty. Every other es path (978/84) is unaffected.

How this fixes it

Drops the 978/13 group from the rules and keeps group 84 only, so every ISBN emitted is structurally well-formed. The 978/13 group with a zero-length registrant is not a usable ISBN shape, so removing it could only have produced the malformed output in question.

Fixes #2472.

AI Assistance Disclosure (REQUIRED)

  • If AI tools were used, I have disclosed which ones, and fully reviewed and verified their output.

Checklist

  • I have read the documentation about CONTRIBUTING
  • I have read the documentation about Coding style
  • I have run make lint

Test plan

pytest tests/providers/test_isbn.py
  without the fix   1 failed, 6 passed
  with the fix      7 passed

@feiiiiii5

Copy link
Copy Markdown
Author

Closing in favour of #2476, opened ~45 min earlier, which covers the same defect.

I also had the premise wrong, and @harmehak0173 corrected it: I treated 978-13 as a Spanish group, but it does not exist in the ISBN standard. Spain's ranges are 978-84 and 979-13, so those four zero-length rules are an invalid group rather than a slip inside a valid one. Their fix removes it and also hardens format() and _check_digit().

Thanks for picking it up, and for checking the agency's RangeMessage.xml rather than taking the report at face value.

@feiiiiii5 feiiiiii5 closed this Oct 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

es_ES isbn13() returns a structurally invalid ISBN ~44% of the time (978-13--0487647-8)

1 participant