Fix /registry route failing on datetime registry values - #110
Open
ramonski wants to merge 2 commits into
Open
Conversation
ramonski
added a commit
that referenced
this pull request
Jul 29, 2026
ramonski
added a commit
that referenced
this pull request
Jul 29, 2026
ramonski
force-pushed
the
fix/registry-datetime-serialization
branch
from
July 29, 2026 14:44
0d69d64 to
6abfb99
Compare
The /registry route returned raw registry values straight to the JSON encoder, which raised 'datetime.datetime(...) is not JSON serializable' for records holding a date or datetime. Coerce such values (and containers of them) to ISO strings before returning, reusing senaite.core.api.dtime for the datetime and Zope DateTime handling.
ramonski
force-pushed
the
fix/registry-datetime-serialization
branch
from
July 29, 2026 15:39
6abfb99 to
f2cc6d7
Compare
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.
Description of the issue/feature this PR addresses
The
/registryroute returns the raw registry values straight to the JSON encoder. When a record holds adateordatetime(some default records do), the encoder raises and the whole route fails:get_registry_records_by_keywordnow coerces such values (and lists, tuples and dicts containing them) to ISO strings before they reach the encoder. ZopeDateTimeis handled too.Current behavior before PR
GET /senaite/v1/registryreturns a 500 with aTypeErrorwhenever any registry record holds a date/datetime value.Desired behavior after PR is merged
Date and datetime registry values are returned as ISO strings, and the route no longer fails. Covered by a new case in
api_settings.rstthat stores aDatetimerecord and asserts the record set is JSON serializable.--
I confirm I have coded it according to PEP8 standards.