Skip to content

fix: handle non-object concepts in validatelanginfofiles - #831

Open
Rajpal14 wants to merge 2 commits into
codethesaurus:mainfrom
Rajpal14:fix/issue-826-concepts-validation
Open

Rajpal14 wants to merge 2 commits into
codethesaurus:mainfrom
Rajpal14:fix/issue-826-concepts-validation

Conversation

@Rajpal14

@Rajpal14 Rajpal14 commented Nov 10, 2026 •

Copy link
Copy Markdown

What GitHub issue does this PR apply to?

Resolves #826

What changed and why?

The check_concepts method in validatelanginfofiles.py previously assumed that the concepts field in a language JSON file is always a dictionary (concepts.items()). When a malformed file contained a non-dictionary data type (such as a list, string, or null), the command crashed with an unhandled AttributeError instead of reporting a validation error and continuing.

This PR:

  1. Adds a type check isinstance(concepts, dict) to check_concepts. If concepts is not an object/mapping, it logs an error in the project's standard format ([Error] \` has a `concepts` section that is not an object`) and safely returns.
  2. Adds a dedicated regression test suite in web/tests/test_validatelanginfofiles_regression.py testing non-dict inputs (list, str, None) to verify error reporting and crash prevention.

AI bots used in the process of making this PR

Google Antigravity & OpenAI ChatGPT were used for codebase exploration, reproducing the issue, and structuring the regression test suite. All code, tests, and diffs were reviewed and verified locally.

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?

All 130 tests pass locally (python manage.py test web).

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