Skip to content

fix: strip kicad prefix from circuit-json and prevent footprinter crashes for library footprints#2037

Closed
techmannih wants to merge 5 commits intotscircuit:mainfrom
techmannih:jaa
Closed

fix: strip kicad prefix from circuit-json and prevent footprinter crashes for library footprints#2037
techmannih wants to merge 5 commits intotscircuit:mainfrom
techmannih:jaa

Conversation

@techmannih
Copy link
Member

@techmannih techmannih commented Mar 11, 2026

This PR addresses issues with loading KiCad footprints by correctly handling the kicad: prefix . It ensures that library-prefixed footprints don't crash the standard footprinter parser and that the prefix is stripped when generating the final Circuit JSON for compatibility with 3D model loaders.

Key Changes

  • Library Prefix Stripping: Implemented prefix stripping in NormalComponent.getFootprinterString(). When a footprint like kicad:Connector_JST/JST_PH_B6B... is used, the kicad: prefix is removed before being stored in cad_component metadata.
  • Improved Footprint Resolution: Updated NormalComponent and Chip rendering phases (doInitialPcbComponentRender, doInitialPartsEngineRender) to use getFootprinterString() instead of raw props.footprint.
  • Parser Guards: Added guards in _addChildrenFromStringFootprint and getPortsFromFootprint to prevent the @tscircuit/footprinter parser from attempting to process strings containing colons (library references). This fixes the Invalid footprint function, got "kicad" crash.
  • Selector Compatibility: Maintained the original prefixed string in props and Footprint source attributes to ensure pcbSx selectors (e.g., & footprint[src^='kicad:']) continue to work.

Bug Fixes

  • Fixed "Invalid footprint function" error when using KiCad footprints.
  • Fixed issue where raw library prefixes were being passed into the final Circuit JSON footprinter_string fields.

fix https://linear.app/tscircuit/issue/TSC-394/kicad-prefix-footprints-are-passed-to-circuit-json-should-be-converted

@vercel
Copy link

vercel bot commented Mar 11, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
tscircuit-core-benchmarks Ready Ready Preview, Comment Mar 11, 2026 6:58pm

Request Review

@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@techmannih techmannih changed the title fix: strip kicad prefix and prevent footprinter crashes for library footprints fix: strip kicad prefix from circuit-json and prevent footprinter crashes for library footprints Mar 11, 2026
@techmannih techmannih requested a review from seveibar March 11, 2026 18:29
Copy link
Contributor

@seveibar seveibar left a comment

Choose a reason for hiding this comment

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

slop implementation

Copy link
Contributor

@seveibar seveibar left a comment

Choose a reason for hiding this comment

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

Solution is wrong. Footprinter string should not be defined

@github-actions
Copy link

This PR has been automatically marked as stale because it has had no recent activity. It will be closed if no further activity occurs.

@github-actions
Copy link

This PR was closed because it has been inactive for 1 day since being marked as stale.

@github-actions github-actions bot closed this Mar 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants