Skip to content

fix(schema): accept string or number for szlcsc/lcsc id - #404

Open
maci0 wants to merge 2 commits into
tscircuit:mainfrom
maci0:fix-szlcsc-id-string-or-number
Open

fix(schema): accept string or number for szlcsc/lcsc id#404
maci0 wants to merge 2 commits into
tscircuit:mainfrom
maci0:fix-szlcsc-id-string-or-number

Conversation

@maci0

@maci0 maci0 commented Jul 6, 2026

Copy link
Copy Markdown

Problem

tsci import <lcsc-id> (and any EasyEDA fetch) crashes for certain parts, e.g. C356849 (Ebyte E73-2G4M08S1C), with:

szlcsc.id: Expected number, received string

EasyEDA's API returns szlcsc.id (and lcsc.id) as a number for some parts and a string for others. SzlcscSchema/LcscSchema hardcode z.number(), so validation throws and the import aborts.

Fix

The id field is not consumed anywhere downstream (only validated), so widen it to z.union([z.number(), z.string()]). A separate number: z.string() field already carries the C... code, so this only relaxes the internal id.

Test

Adds a no-network unit test asserting both schemas accept a numeric and a string id.

maci0 added 2 commits July 6, 2026 14:32
EasyEDA returns the szlcsc.id (and lcsc.id) field as a number for some parts and
as a string for others (e.g. C356849). SzlcscSchema/LcscSchema hardcoded
z.number(), so parsing crashed with 'szlcsc.id: Expected number, received
string' and 'tsci import <lcsc>' failed for every affected part. The field is
unused downstream, so widen it to z.union([z.number(), z.string()]). Adds a
no-network regression test.
@maci0

maci0 commented Jul 14, 2026

Copy link
Copy Markdown
Author

Still relevant and CI-green — poking to avoid the stale auto-close. Accepting a string OR number for the szlcsc/lcsc id fixes import stability when the id arrives as a string. Happy to address any review notes.

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.

1 participant