Build a property URI a field name cannot break, and say why SEEK refused - #224
Merged
Conversation
A field named "Source Name" became http://schema.org/Source Name, which SEEK rejects as not a valid URI -- failing the whole Sample Type and naming no attribute, while rdflib warned the same URI would break on serialization. Provisioning and the data RDF now derive it through one percent-encoding helper, because SEEK matches an imported sample to its attribute by that URI and the two must agree exactly. A name needing no encoding is unchanged, so nothing already registered in an instance moves. The refusal itself was unreadable: httpx's bare "422 Unprocessable Content" and a link to MDN. SEEK answers with a JSON:API errors array naming the offending attribute, so raise that instead -- it is what identified this bug.
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.
Provisioning a profile to a live SEEK 1.18.1 failed with:
The bug
One field is named
Source Name.pid=f"{_PID_BASE}{field.name}"made thathttp://schema.org/Source Name, and SEEK validates the pid: it rejected the entire Sample Type over one attribute, naming none of them. rdflib was equally unhappy on the other side, warning the same URI "does not look like a valid URI, trying to serialize this will break".Both sides now derive the URI through one helper,
metaseed.seek.naming.property_uri, which percent-encodes the local name. It has to be one helper rather than two fixes: SEEK matches an FDS-imported sample to its Sample Type attribute by this URI, so provisioning and the data RDF must produce byte-identical values or an import silently matches nothing. A name that needs no encoding is returned unchanged, so every URI already registered in a SEEK instance stays where it is — nothing to migrate.Why it took a live instance to find
The error surfaced to the user was httpx's bare status line plus a link to MDN. SEEK answers a rejected write with a JSON:API
errorsarray naming the offending attribute, and we discarded it.SeekApiErrornow parses and raises it:That one line identified the bug immediately, after four blind attempts. Every SEEK failure was previously unactionable in the same way.
Verified
Against the reporter's SEEK 1.18.1 after the fix:
created: ['Sample Type: cropxr-metabolomics Source'], no errors, Sample Type id 21.58 SEEK tests pass, four new: the space is encoded, an ordinary name is untouched, every planned pid parses as an absolute URI, and the data RDF emits the same URI provisioning registers.