Skip to content

Validate category field before use as dict key in CSR appendix generation#236

Merged
james-ball-qualcomm merged 2 commits intoadd_csr_tablefrom
copilot/sub-pr-235
Mar 25, 2026
Merged

Validate category field before use as dict key in CSR appendix generation#236
james-ball-qualcomm merged 2 commits intoadd_csr_tablefrom
copilot/sub-pr-235

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 25, 2026

category was retrieved from CSR data with a silent "" default and used directly as a (csr_dir, category) dict key. An unrecognized, empty, or non-string category would silently drop CSRs from the WARL/WLRL grouped tables rather than producing a controlled error.

Changes

  • tools/create_csr_appendix.pywrite_output_files: replace the unvalidated csr.get("category", "") with explicit checks:
    • Fatals if category is missing, empty, or not a string
    • Fatals if category is not in IMPLDEF_CATEGORIES, listing allowed values in the error message
# Before
category = csr.get("category", "")
chapter_category_files.setdefault((csr_dir, category), []).append(f"{file_stem}.adoc")

# After
category_value = csr.get("category")
if not isinstance(category_value, str) or not category_value:
    fatal(f"Expected non-empty category for CSR {name!r}")
category: str = category_value
if category not in IMPLDEF_CATEGORIES:
    allowed_str = ", ".join(IMPLDEF_CATEGORIES)
    fatal(
        f"Unrecognized category {category!r} for CSR {name!r}; "
        f"allowed values are: {allowed_str}"
    )
chapter_category_files.setdefault((csr_dir, category), []).append(f"{file_stem}.adoc")

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI changed the title [WIP] [WIP] Address feedback on WARL/WLRL CSR AsciiDoc appendix include files Validate category field before use as dict key in CSR appendix generation Mar 25, 2026
@james-ball-qualcomm james-ball-qualcomm merged commit 038159e into add_csr_table Mar 25, 2026
2 checks passed
@james-ball-qualcomm james-ball-qualcomm deleted the copilot/sub-pr-235 branch March 25, 2026 18:55
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.

3 participants