Skip to content

Report non-object concepts in validatelanginfofiles instead of crashing - #827

Open
murainah wants to merge 1 commit into
codethesaurus:mainfrom
murainah:issue-826-validator-non-object-concepts
Open

murainah wants to merge 1 commit into
codethesaurus:mainfrom
murainah:issue-826-validator-non-object-concepts

Conversation

@murainah

@murainah murainah commented Nov 8, 2026

Copy link
Copy Markdown

What GitHub issue does this PR apply to?

Resolves #826

What changed and why?

validatelanginfofiles crashed with AttributeError: 'list' object has no attribute 'items' when a language file was valid JSON but its concepts value was not an object (for example "concepts": []), instead of reporting a validation error.

check_concepts now checks that concepts is 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:

[Error] `langs/python/3/data_types.json` has a `concepts` section that is not an object

Following AGENTS.md (TDD), I added the regression test first (test_validatelanginfofiles_reports_non_object_concepts in web/tests/test_commands.py). It runs the real validate_language_file path on a temporary file. It failed with the AttributeError before the fix and passes after it. Valid files behave exactly as before.

Checks I ran locally:

  • python manage.py test: 130 tests pass
  • python manage.py validatemetainfofile and python manage.py validatelanginfofiles: no errors on the real data
  • isort --profile black --check-only is clean on the two files I changed

AI 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

  • I claimed any associated issue(s) and they are not someone else's
  • I have looked at documentation to ensure I made any revisions correctly
  • I tested my changes locally to ensure they work
  • For language files, I have validated the edited files are valid JSON and data shows up correctly
  • For website code edits, I have added or edited any appropriate unit tests for my changes
  • If I used artificial intelligence (AI), I have reviewed the suggested changes and ensured they work correctly

Any additional comments or things to be aware of while reviewing?

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

No deployments
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.

validatelanginfofiles crashes with AttributeError when "concepts" is not a JSON object

1 participant