fix(schema): accept string or number for szlcsc/lcsc id - #404
Open
maci0 wants to merge 2 commits into
Open
Conversation
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.
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
tsci import <lcsc-id>(and any EasyEDA fetch) crashes for certain parts, e.g.C356849(Ebyte E73-2G4M08S1C), with:EasyEDA's API returns
szlcsc.id(andlcsc.id) as a number for some parts and a string for others.SzlcscSchema/LcscSchemahardcodez.number(), so validation throws and the import aborts.Fix
The
idfield is not consumed anywhere downstream (only validated), so widen it toz.union([z.number(), z.string()]). A separatenumber: z.string()field already carries theC...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.