Skip to content
This repository was archived by the owner on Apr 22, 2026. It is now read-only.

Fix boolean parsing, add lenient unknown-field handling, include dist/#17

Merged
natarius merged 3 commits into
masterfrom
devin/1772469835-fix-bool-wrapping-and-dist
Mar 2, 2026
Merged

Fix boolean parsing, add lenient unknown-field handling, include dist/#17
natarius merged 3 commits into
masterfrom
devin/1772469835-fix-bool-wrapping-and-dist

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Mar 2, 2026

Copy link
Copy Markdown

Summary

Three sets of changes to the KiCad symbol parser:

1. Fix boolean double-wrapping (8 rules)

The bool rule already returns { type: "boolean", value: true/false }, but 8 action blocks were re-wrapping it by comparing the object to the string "yes" (always evaluating to false). Changed all 8 to pass through the bool result directly with return { type, value }.

Affected rules: embedded_fonts, in_pos_files, duplicate_pin_numbers_are_jumpers, show_name, do_not_autoplace, exclude_from_sim, in_bom, on_board

2. Make parser lenient: skip unknown fields gracefully

Added an unknown_sexp catch-all rule that matches any balanced parenthesised S-expression and returns null. This rule is appended as the last alternative in all choice lists so known fields still parse normally, but unknown future fields (e.g. from KiCad 11+) are silently skipped instead of causing parse failures.

Updated alternation lists: kicad_symbol_lib, kicad_symbol_element, property, pin, stroke_definition, effects, font

All collection rules now filter out null values returned by unknown_sexp.

3. Track dist/ in git

Removes dist/ from .gitignore so built artifacts are committed. This is needed because pnpm git dependencies fetch tarballs containing only tracked files — without dist/, consumers (like flux-app) get an empty package.

Review & Testing Checklist for Human

  • Verify the unknown_sexp catch-all doesn't silently swallow valid fields. Since it's always last in alternation, known rules should match first. However, if a known rule fails mid-match (e.g. a property has a new inner structure), unknown_sexp would consume and discard it. This is the intended trade-off for leniency — but worth verifying with a complex real-world file.
  • Verify balanced_content handles edge cases. The rule depends on the existing string rule for quoted strings inside unknown S-expressions. Confirm it doesn't choke on strings containing escaped parens or unusual characters.
  • Verify tracking dist/ in git is acceptable for this project's workflow. It means dist/ must be rebuilt and committed whenever source changes.
  • Run pnpm test to confirm all tests pass with both the boolean fixes and lenient parsing.
  • Suggested manual test: Create a fake .kicad_sym file with an invented field like (some_future_field 42) inside a symbol and confirm it parses without error.

Notes


Open with Devin

… repo

- Fix embedded_fonts, in_pos_files, duplicate_pin_numbers_are_jumpers,
  show_name, do_not_autoplace rules to pass bool value through directly
  instead of double-wrapping (value === 'yes' on an object always yields false)
- Remove dist/ from .gitignore so pnpm git dependencies resolve correctly
  (dist/ contains the built package needed by consumers)

Co-Authored-By: Matthias <matthias.chills@gmail.com>
@devin-ai-integration

Copy link
Copy Markdown
Author
Original prompt from Matthias
SYSTEM:
=== BEGIN THREAD HISTORY (in #dogfooding) ===
Thea (U0AFH6R3D8D): Given the speed the EAGLE, EasyEDA and other imports (seem) to have been implemented. Could we get a KiCad Import that works with the newest filetype?  No KiCad file that was created in the last 5 year works. The last supported version seems to be KiCad 5 and soon KiCad 10 will be launching.

Giulio (U091GFANVAT): Mmm weird since we are using kicad 9 internally 

Giulio (U091GFANVAT): I think it’s a matter of correctly mapping the kicad features into flux 

Thea (U0AFH6R3D8D): Its a biig Painpoint.

Thea (U0AFH6R3D8D): CC @matthias (U0852RD7LMP)

matthias (U0852RD7LMP): What exactly doesn't work?

Thea (U0AFH6R3D8D): Import of symbols and footprints created in a recent KiCad version just fail

matthias (U0852RD7LMP): Can you put together a folder of test files please

matthias (U0852RD7LMP): This is the first time I hear about this issue

matthias (U0852RD7LMP): @Jharwin (U091GF9SA5V) @Nicolas Tzovanis (U084Q3S45U3) is this a regressions?

Nicolas Tzovanis (U084Q3S45U3): Afaik we supported up to kicad v6

Nicolas Tzovanis (U084Q3S45U3): And kicad 9 uses the same format as kicad v6 for parts. Not sure what the deal is with Kicad 10 though.

Thea (U0AFH6R3D8D): 

ATTACHMENT:"https://app.devin.ai/attachments/a644df82-7cda-43c6-b42e-26affadf9653/image.png"

Thea (U0AFH6R3D8D): Currently making a Test folder.

Nicolas Tzovanis (U084Q3S45U3): Did the format change on Kicad 10?

matthias (U0852RD7LMP): @Devin please investigate
=== END THREAD HISTORY ===

Thread URL: https://fluxaigroup.slack.com/archives/C09286X4F7Y/p1772466774920479?thread_ts=1772466774.920479&cid=C09286X4F7Y

The latest message is the one right above that tagged you.

@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

devin-ai-integration[bot]

This comment was marked as resolved.

Same class of bug as the 5 rules fixed earlier: bool rule returns
{type, value} object but these rules compared it to string 'yes',
always evaluating to false. Now pass through the bool value directly.

Co-Authored-By: Matthias <matthias.chills@gmail.com>
Add unknown_sexp catch-all rule that matches any balanced parenthesised
form and returns null. This rule is added as the last alternative in all
choice lists (kicad_symbol_lib, kicad_symbol_element, property, pin,
stroke, effects, font) so known fields parse normally but unknown future
fields are silently skipped instead of causing parse failures.

This ensures KiCad 11+ format changes won't break the parser.

Co-Authored-By: Matthias <matthias.chills@gmail.com>
@devin-ai-integration devin-ai-integration Bot changed the title Fix boolean double-wrapping in grammar rules and include dist/ in repo Fix boolean parsing, add lenient unknown-field handling, include dist/ Mar 2, 2026
@natarius
natarius merged commit 05192d9 into master Mar 2, 2026
4 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant