Closed bug report

install_symbol: 'No symbols found' on a valid .kicad_sym whose top-level symbol is at column 0 (regex requires indentation)

Colby Knox · ·closed by John Lauer

install_symbol "No symbols found in the provided file content" on a valid .kicad_sym whose top-level symbol is at column 0

Live, bridge 0.9.186, KiCad 10.0, Colby-ROG2. kicad_install_symbol fails on a valid, complete KiCad 10 symbol file:

kicad_install_symbol {fileContent:<base64 of lm1117.kicad_sym>, fileName:"lm1117.kicad_sym", quietInstall:true}
-> success:false, error:"No symbols found in the provided file content"

The file is well-formed: 2540 bytes, parens balanced (109/109), generator kicad_symbol_editor 10.0, (version 20251024), three (symbol "..." blocks: LM1117DT-3.3 (top level) + LM1117DT-3.3_0_1 + LM1117DT-3.3_1_1 (its sub-units). It renders fine in the wiki's own symbol viewer.

Root cause

bridges/kicad/adom_library.py extracts top-level symbols with a regex that REQUIRES leading whitespace:

# line 168
for m in re.finditer(r'^[ \t]+\(symbol\s+"([^"]+)"', text, re.MULTILINE):
    ...
    if re.search(r"_\d+_\d+$", name):   # skip sub-units
        continue
# (and _SYMBOL_NAME_RE at line 26: r'^\s+\(symbol\s+"([^"]+)"')

But in this file the TOP-LEVEL symbol line has NO indentation, while the sub-units are indented two tabs:

line 5:   (symbol "LM1117DT-3.3"          <- column 0, no leading whitespace
line 87:  \t\t(symbol "LM1117DT-3.3_0_1"   <- indented
line 100: \t\t(symbol "LM1117DT-3.3_1_1"   <- indented

So ^[ \t]+ matches only the two sub-units, which are then dropped by the _\d+_\d+ suffix filter -> zero top-level symbols -> "No symbols found". (Note the comment at adom_library.py:161-167 says ^[ \t]+ was itself the FIX for an earlier "No symbols found" where symbols were indented; this file is the mirror case.)

Why the file looks like that

Indentation is not semantic in s-expressions, and this file is inconsistent (version/generator are 1-tab indented, the top-level symbol is at column 0), so it was likely hand-edited or produced by a non-KiCad tool even though the generator stamp says kicad 10. The wiki serves it verbatim. The point is a robustness one: a valid .kicad_sym should install regardless of indentation.

Fix

Match a top-level (symbol with ZERO-OR-MORE leading whitespace, and rely on the existing _\d+_\d+ sub-unit filter to exclude nested units:

re.finditer(r'^[ \t]*\(symbol\s+"([^"]+)"', text, re.MULTILINE)   # + the same on _SYMBOL_NAME_RE

That handles column-0 AND indented top-level symbols without re-admitting sub-units (they still carry the _N_N suffix). Repro file: https://wiki.adom.inc/ray/lm1117 (lm1117.kicad_sym). Happy to run the install live again after a fix.

1 Reply

John Lauer ·

Closing - fixed in 0.9.193 and verified end to end on real hardware, not just against the regex.

Cause: ^[ \t]+\(symbol " required leading whitespace, so a library whose top-level (symbol starts at column 0 parsed as having no symbols. Now ^[ \t]*.

Verified by writing a genuine column-0 .kicad_sym to a box and installing it:

kicad_install_symbol {filePath: ".../COL0-TEST.kicad_sym"}
-> success, symbolNames: ["COL0-TEST"]

That same test turned up two adjacent bugs, both since fixed: libraryName was silently swallowed (now returns ignoredArgs and says so), and a Symbol Editor open BEFORE an install cannot see the new symbol at all - its library index predates it. That one now reports errorCode: library_cache_stale with a rescan:true remedy instead of a misleading "didn't load in the background".

John Lauer closed this ·

Log in to reply.