Skip to content

fix: set f_ref in SchematicComponentV6.set_ref() for KiCad 9 compat#932

Open
telagod wants to merge 113 commits into
INTI-CMNB:devfrom
telagod:fix/v6-sch-f_ref-kicad9
Open

fix: set f_ref in SchematicComponentV6.set_ref() for KiCad 9 compat#932
telagod wants to merge 113 commits into
INTI-CMNB:devfrom
telagod:fix/v6-sch-f_ref-kicad9

Conversation

@telagod

@telagod telagod commented Jun 9, 2026

Copy link
Copy Markdown

Summary

  • SchematicComponentV6.set_ref() sets self.ref but never self.f_ref
  • When a KiCad 9 schematic component is missing one of the 4 basic fields (Reference/Value/Footprint/Datasheet), _solve_fields() in v5_sch.py:1073 accesses self.f_ref for the warning message
  • This causes AttributeError: 'SchematicComponentV6' object has no attribute 'f_ref'
  • KiCad 9 changed how fields are stored — fewer default fields in the instance — so this hits virtually all KiCad 9 schematics

The fix

One line: self.f_ref = ref in set_ref(), mirroring what the V5 parsing path does.

def set_ref(self, ref):
    self.ref = ref
    self.f_ref = ref    # <-- added
    self.split_ref()
    self.set_field('Reference', ref)

Traceback

File "kibot/kicad/v6_sch.py", line 3055, in load
    comp.set_ref(s.reference)
File "kibot/kicad/v6_sch.py", line 1269, in set_ref
    self.set_field('Reference', ref)
File "kibot/kicad/v5_sch.py", line 955, in set_field
    self._solve_fields(LineReader(None, '**Internal**'))
File "kibot/kicad/v5_sch.py", line 1073, in _solve_fields
    logger.warning(W_MISCFLD + 'Component `{}` without the basic fields'.format(self.f_ref))
                                                                                ^^^^^^^^^^
AttributeError: 'SchematicComponentV6' object has no attribute 'f_ref'

Test plan

  • Tested with KiBot 1.9.0 + KiCad 9.0.9 on a 91-component board (ESP32-C3, HV boost, USB-C)
  • Before fix: crash on bom, render_3d, erc, pdf_sch_print — any output that calls GS.load_sch()
  • After fix: all pass. Warnings about "without the basic fields" are expected and harmless (W036)
  • BOM CSV output is correct (92 lines, all components present)
  • ERC preflight runs to completion (186 unique warnings, 0 errors)
  • PCB-only outputs (gerber, drill, position) still work as before

set-soft and others added 30 commits October 12, 2022 13:20
- Also documented `install3D` option
- The `dev` images must be created from `dev`
- Coverage information should be from `dev`
don't show warning if footprint has attribute "not in schematics"
set-soft and others added 27 commits September 25, 2024 08:19
The workflow is currently broken, fails to upload the .deb package
All seems to be ok, most probably some incompatibility with the
new artifacts-download (which is really incompatible)
Doesn't seem to be needed, but adds coherence
* Add the same flag from the PDF export for using the aux origin
  for the export.
…-aux-origin

[SVG Export][Added] Flag for using aux origin
Adds `code` and `arg` options to support plugin type for fiducials in
panelization.
…ze_fiducials_plugin_options

Config: Panelize: Add missing fiducials plugin options
Use Kicad major version for 3rdparty path
No more KiCad 5 releases
SchematicComponentV6.set_ref() sets self.ref but never self.f_ref.
When a KiCad 9 schematic component is missing one of the 4 basic
fields (Reference/Value/Footprint/Datasheet), _solve_fields() in
v5_sch.py:1073 accesses self.f_ref for the warning message, causing:

  AttributeError: 'SchematicComponentV6' object has no attribute 'f_ref'

This crashes KiBot on virtually all KiCad 9 schematics because KiCad 9
changed how fields are stored (fewer default fields in the instance).

The fix mirrors what the V5 parsing path does — f_ref is assigned
during component reference resolution.

Tested with KiBot 1.9.0 + KiCad 9.0.9 on a 91-component board.
Before: crash on any output that loads the schematic (bom, render_3d,
erc, pdf_sch_print). After: all pass (warnings about missing basic
fields are expected and harmless).
@set-soft

set-soft commented Jun 9, 2026

Copy link
Copy Markdown
Member

Hi @telagod !

  1. You need to rebase this patch, use git rebase -i HASH_FOR_THE_LAST_PATH_IN_DEV and let just the last entry.
  2. When you say KiCad 9 I guess you are talking about KiCad 9.0.9, right? I have 9.0.8 installed and never saw this problem.

If rebasing it is complex for you I can just apply it manually, but then I'll have to drop this PR.

set-soft added a commit that referenced this pull request Jun 11, 2026
@set-soft

Copy link
Copy Markdown
Member

Hi @telagod !
Do you still interested on it?

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.