Skip to content

Normalize UID references through the field manager, not the setter - #100

Open
ramonski wants to merge 2 commits into
feature/report-create-errorsfrom
feature/normalize-dx-uid-references
Open

Normalize UID references through the field manager, not the setter#100
ramonski wants to merge 2 commits into
feature/report-create-errorsfrom
feature/normalize-dx-uid-references

Conversation

@ramonski

Copy link
Copy Markdown
Contributor

What

DexterityDataManager.set now routes UID reference fields through their field manager instead of a content-type set<Name> mutator, so reference values are normalized before they are stored.

Why

DexterityDataManager.set prioritized a set<Name> setter over the field manager. For a UID reference field (for example Department.manager), the auto-generated setter just calls the field mutator with the raw value, bypassing UIDReferenceFieldMixin's normalization (resolve objects/paths, coerce UIDs to native str).

A UID posted as JSON arrives as unicode. Stored verbatim, it then fails the field's validation, because UIDReferenceField is a List whose value_type is ASCIILine (native str in py2):

POST .../Department/create  {"manager": "cc954ed8..."}
-> {"manager": "WrongContainedType"}

This blocked creating any object with a required single-valued DX UID reference through the API (Department, and therefore AnalysisCategory, ...).

Change

In DexterityDataManager.set, skip the raw setter and use the field manager when the field manager is a UIDReferenceFieldMixin (AT or DX UID reference). The field manager normalizes the value and still ends at the field mutator, so no setter side effects are lost; all other fields keep using their setter.

Verification

Reproduces with Department.manager via the JSON API before the change (WrongContainedType) and creates successfully after. Pairs with #99, which surfaced the underlying error in the first place.

Stacking

Stacked on top of #99 (feature/report-create-errors).

ramonski added a commit that referenced this pull request Jul 27, 2026
ramonski added 2 commits July 27, 2026 12:32
DexterityDataManager.set prioritized a content-type set<Name> mutator
over the field manager. For a UID reference field (e.g. Department's
manager) that bypassed UIDReferenceFieldMixin's normalization, so a
unicode UID from a JSON payload was stored verbatim and later failed the
field's ASCIILine value_type validation with WrongContainedType.

Route UID reference fields through their field manager (which resolves
objects/paths and coerces UIDs to native str). Every other field keeps
prioritizing the setter, which also covers BBB properties that have no
schema field (e.g. Department.DepartmentID).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug 🐞 Something is broken

Development

Successfully merging this pull request may close these issues.

1 participant