Skip to content

Validate required bootloader fields before dictionary access#7

Merged
h2zero merged 3 commits intodevfrom
copilot/sub-pr-5
Jan 21, 2026
Merged

Validate required bootloader fields before dictionary access#7
h2zero merged 3 commits intodevfrom
copilot/sub-pr-5

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 21, 2026

Addresses feedback from PR #5 review: accessing selected_bl["bootloader_file"], selected_bl["linker_script"], selected_bl["max_size"], and selected_bl["max_ram_size"] without validation raises KeyError on incomplete board configurations.

Changes

  • Validation: Check for required fields (bootloader_file, linker_script, max_size, max_ram_size) before dictionary access
  • Error handling: Exit with descriptive error message listing missing fields and bootloader name
# Before
if selected_bl:
    env.Replace(BOOTLOADERHEX=join(FRAMEWORK_DIR, "variants", 
                board.get("build.variant", ""), selected_bl["bootloader_file"]))

# After  
if selected_bl:
    required_fields = ["bootloader_file", "linker_script", "max_size", "max_ram_size"]
    missing_fields = [field for field in required_fields if field not in selected_bl]
    if missing_fields:
        sys.stderr.write("Error. Bootloader '%s' is missing required fields: %s\n" %
                        (selected_bl.get("name", "unknown"), ", ".join(missing_fields)))
        env.Exit(1)
    
    env.Replace(BOOTLOADERHEX=join(FRAMEWORK_DIR, "variants",
                board.get("build.variant", ""), selected_bl["bootloader_file"]))

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits January 21, 2026 20:00
Co-authored-by: h2zero <32826625+h2zero@users.noreply.github.com>
Co-authored-by: h2zero <32826625+h2zero@users.noreply.github.com>
@h2zero h2zero marked this pull request as ready for review January 21, 2026 20:03
Copilot AI changed the title [WIP] WIP address feedback on bootloader options update PR Validate required bootloader fields before dictionary access Jan 21, 2026
Copilot AI requested a review from h2zero January 21, 2026 20:03
@h2zero h2zero merged commit 7cc00d2 into dev Jan 21, 2026
@h2zero h2zero deleted the copilot/sub-pr-5 branch January 21, 2026 20:04
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.

2 participants