Repository navigation
Conversation
check_concepts assumed `concepts` was a dict, so a language file with
valid JSON like {"concepts": []} raised AttributeError. Report a
validation error instead, and add a regression test.
Refs codethesaurus#826
Signed-off-by: Abubakri <murainahabubakri@gmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What GitHub issue does this PR apply to?
Resolves #826
What changed and why?
validatelanginfofilescrashed withAttributeError: 'list' object has no attribute 'items'when a language file was valid JSON but itsconceptsvalue was not an object (for example"concepts": []), instead of reporting a validation error.check_conceptsnow checks thatconceptsis a dict. If it isn't, it reports an error in the validator's usual style and returns, so the command keeps going and counts the error:Following AGENTS.md (TDD), I added the regression test first (
test_validatelanginfofiles_reports_non_object_conceptsinweb/tests/test_commands.py). It runs the realvalidate_language_filepath on a temporary file. It failed with theAttributeErrorbefore the fix and passes after it. Valid files behave exactly as before.Checks I ran locally:
python manage.py test: 130 tests passpython manage.py validatemetainfofileandpython manage.py validatelanginfofiles: no errors on the real dataisort --profile black --check-onlyis clean on the two files I changedAI bots used in the process of making this PR
I used Claude (Anthropic's AI assistant) to help me find this project, to draft the issue text (#826), and to help write the regression test and the fix. I reproduced the crash myself in the Django shell, ran the new test to confirm it failed first, applied the change, and ran the full test suite, both validators and isort. I read the code I'm submitting and understand it.
Checklist
Any additional comments or things to be aware of while reviewing?
conceptssection. The same kind of crash can happen for the other non-object cases listed in validatelanginfofiles crashes with AttributeError when "concepts" is not a JSON object #826 (a non-object top-level value,meta, or an individual concept entry). I left them out to keep the change small, and I can do them in a follow-up PR if you'd like.