Repository navigation
Conversation
Two separate faults, both of which end as a WrongContainedType or a WrongType on a field the request never mentions. #106 unwrapped a single valued reference from its list to a bare UID. An Archetypes UIDReferenceField needs that, and refuses a list with "[...] is not supported". A Dexterity UIDReferenceField derives from zope.schema List and validates as one, so the bare UID fails before it is ever stored, and setting e.g. a department's manager through the API stopped working. The unwrapping moves to the Archetypes field manager, through a to_field_value hook, so each side is handed the shape its own validator expects. The second fault is older and was hiding behind the first. A Dexterity type migrated from Archetypes keeps the old capitalised name as a BBB property, and a payload written against the old API uses it. get_field looked the name up exactly, so the schema field was not found and the data manager fell back to the BBB setter. Some of those setters convert the value, and many hand it to the mutator as it came: a duration stays the mapping JSON carried, a UID stays unicode. The schema spellings are tried after the exact name, and only a candidate naming a real field is used. There are 140 of these BBB properties on Dexterity content, and 112 of them name a schema field. Lowering the first letter reaches 43; the rest are snake case. A few keep neither convention (a sample template calls its field `samplepoint`), which is why the plain lower case form is tried too. The new doctest covers both faults, and fails if either fix is reverted.
ramonski
force-pushed
the
fix/single-valued-dx-uidreference
branch
from
October 7, 2026 07:28
21ab0f5 to
759f4f6
Compare
A name in a record that matched no field and no setter was dropped
with a line in the log, and the request answered that the object had
been created or updated. A caller asking for `Service` instead of
`services` was told that all was well and got back a profile with
nothing in it, which is how an afternoon goes missing.
It is refused now, and the message names the field the caller probably
meant:
No field named 'Service' on AnalysisProfile. Did you mean 'services'?
The keys that address the object or steer the request rather than
naming a field (portal_type, parent_path, parent_uid, path, uid, id,
transition) are listed as such and skipped, as `id` already was.
This builds on #115. A name a Dexterity type kept from its Archetypes
days has to reach its field first; without that, every payload written
against the documented API, which uses those names throughout, would
now be refused.
ramonski
force-pushed
the
fix/refuse-unknown-fields
branch
from
October 7, 2026 07:29
59dea71 to
ab7a434
Compare
A file field reads the filename and the content type from the payload rather than from a field of its own, so a request that uploads a file carries `filename` and, optionally, `mimetype` or `content_type` beside the field itself. Refusing a name that is no field turned those three into a 400 on every file upload. They address the request rather than the object, which is what the control keys are, so they belong in that tuple.
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.
A name in a record that matches no field and no setter is dropped with a line in the log, and the request answers that the object has been created or updated.
Current behavior before PR
Both keys are gone and the caller is told all is well. This is how an afternoon goes missing: the typo was
Serviceforservices, a spec reported fifty-eight objects composed, and the profile it had just written stayed empty.The code says so plainly:
DexterityDataManager.setreturns False when it finds neither a schema field nor a setter for the name.Desired behavior after PR is merged
Without a field close enough to suggest, it says only what it knows:
The suggestion comes from
difflib.get_close_matchesover the object's own field names.The keys that are not fields
A record also carries keys that address the object or steer the request, and those must not be mistaken for fields. They are named now, where only
idwas before:That list is the set of keys the routes themselves read out of a record.
A note on what this changes for callers
A payload carrying a key that is not a field is refused where it used to be accepted. That is the point, and it is worth saying out loud: an integration that sends something extra and harmless will see a 400 it did not see before. The alternative is what we have today, which is that a typo in a field name is indistinguishable from success.
Verification
bin/test-senaite -s senaite.jsonapi: 41 tests, 0 failures, 0 errors, run against a tree carrying Validate only the submitted fields on update #107, Fix single valued Dexterity UID references not settable #115 and this change together, which is the combination that matters.uidreferences.rstcovers both messages, the one with a suggestion and the one without.create.rstuses throughout (Department,Category,Methods,Method) still go through, which is what makes Fix single valued Dexterity UID references not settable #115 a prerequisite rather than a convenience.I confirm I have tested the PR thoroughly and coded it according to PEP8 standards.