Skip to content

Conversation

@sergicasau
Copy link

Description of the issue/feature this PR addresses

UIDReferenceField fields internally rely on ASCIILine, which only accepts native str values in Python 2. However, due to legacy Archetypes behavior and the JSONAPI request handling pipeline, incoming field values are always decoded as unicode before validation. As a result, JSONAPI delivers unicode UIDs while the underlying zope.schema validation layer expects str bytes, causing a WrongType error. This mismatch does not occur in standard UI forms because Archetypes/Dexterity widgets convert or coerce values differently, but JSONAPI exposes the type inconsistency directly.

Current behavior before PR

Validator rises a WrongType error when a unicode value is set for UIDReferenceField type fields.

Desired behavior after PR is merged

Validator does not fail when a unicode is set for UIDReferenceField type fields via jsonapi.

--
I confirm I have tested this PR thoroughly and coded it according to PEP8
and Plone's Python styleguide standards.

@sergicasau sergicasau marked this pull request as draft December 9, 2025 16:24
@sergicasau sergicasau marked this pull request as ready for review December 9, 2025 16:32
@ramonski
Copy link
Contributor

Thanks @sergicasau, would you mind to add a Changelog entry for this PR?

@ramonski
Copy link
Contributor

Please also note, that we have some failing tests introduced by this PR.
Maybe it makes sense to fix it rather on the senaite.jsonapi side instead of changing the schema field?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants