Repository navigation
Conversation
Four validators read the value they check back out of the request, because an Archetypes sub-field validator is handed one cell at a time and the checks are about the record as a whole. Three of them took the request with a default for a missing key, which does not help: whole object validation passes REQUEST explicitly as None, so the default never applies and the next line raises on it. No form, nothing to check. They return and leave the value to the field, exactly as for a type whose records never pass through a browser. Reproduced on the analysis service's DefaultResult, which refuses every service with a default result set through the API or an import. The uncertainties one does the same. The other two are the same two lines, found by reading the file rather than by hitting them.
ramonski
force-pushed
the
fix/uncertainties-validator-without-request
branch
from
October 8, 2026 11:23
0ee615c to
3ea6c44
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
Four validators in
bika/lims/validators.pyread the value they check back out of the request. They have to, in a way: an Archetypes sub-field validator is handed one cell at a time, and the checks are about the record as a whole, so the validator looks the whole value up again by field name and runs once per submit.That works for the edit form and nowhere else. Setting the field programmatically, through the JSON API or an import, leaves nothing in the form. Three of the four take the request with a default for a missing key, which does not help: whole-object validation passes
REQUESTexplicitly asNone, sokwargs.get("REQUEST", {})returns theNonerather than the default, and the next line raises on it.service_defaultresult_validatorAnalysisService.DefaultResultrequest.get(...)uncertainties_validatorAnalysisService.Uncertaintiesrequest[...]service_conditions_validatorAnalysisService.Conditionsrequest.get(...)container_prepreservation_validatorContainer.PrePreservedrequest.formCurrent behavior before PR
Creating an analysis service with a default result through the API:
The same with uncertainty ranges, where the subscript raises a
KeyErrorthat reaches the client as a 500:Desired behavior after PR is merged
No form, nothing to check. The validator returns and leaves the value to the field, exactly as for a type whose records never pass through a browser.
Two lines each:
kwargs.get("REQUEST") or {}, so an explicitNonefalls back to the empty mapping, and a guard before the value is read.Verification
Reproduced on
DefaultResultand onUncertainties, both creating cleanly after the change and both still validated on the edit form, where the form carries the field and the validator still runs over every row.The other two are the same two lines and are fixed in the same pass.
service_conditions_validatorturns out not to be reached on this path today, which the same probe shows, andcontainer_prepreservation_validatorbelongs to the ArchetypesContainer. Neither was reproduced; both are included because leaving a known instance of a defect next to a fixed one is how it comes back.The two validators that were already guarded, with
kwargs.get("REQUEST") or {}, are untouched.Full
senaite.coretest suite: 229 tests, 0 failures, 0 errors.--
I confirm I have tested this PR thoroughly and coded it according to PEP8
and Plone's Python styleguide standards.