Fix defects of build_response and the field-type check found in review #23
Labels
No labels
coordination/cross-repo
coordination/needed
effort
large
effort
medium
effort
small
meta/duplicate
meta/planning
meta/wontfix
priority
high
priority
low
priority
medium
session
blocker
session
handover
session
next
status
blocked
status
done
status
in-progress
status
review
status
to-go
type
admin
type
bug
type
config
type
deployment
type
docs
type/documentation
type
enhancement
type
feature
type
handover
type
infrastructure
type
installation
type
maintenance
type
migration
type/refactor
type
research
type
security
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
DAW/daw-modul-berhtjan-core#23
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
A code review of
build_response(response.lua) and the field-type check(fieldtype.lua) found defects that were reproduced with small inputs on
Lua 5.1 and 5.4:
multiple: only the list part of the value is checked. For a fieldwith the values
a,bthe values{ "a", extra = "bogus" },{ x = "bogus" }and{ "a", nil, "bogus" }give a valid response.{}and{ "a", "a" }are accepted too, althoughcli.selectrefuses duplicates.
the caller changes
response.data.value(a response is never modifiedafter creation).
declared_valuesusesentry.value or entry: an entry{ value = false, message = "No" }declares the entry table itself,not
false, and an object withoutvalueis its own value.collection.values = { 0/0, "a" }raises a Lua error (table index is NaN) instead of returningnil, err; the check of the field doesnot look into
values.#required-cardinality;the contract example
invalid-cardinality-valueexpects#closed-cardinality-vocabulary.collection.source,resource.kind,constraint keys) is only checked when
selectionis present.lang.lua(no_language_resolvable) has an error site without aresource_id.Scope
Fix each defect with a test first. Keep the behaviour that the contract
and the existing tests define. Points 6 and 3 touch what the contract
says about
valuesentries (DAW/daw-contracts#17); where the contract issilent the code reports an error and does not guess.
Acceptance criteria
fragjan code .andmake test(Lua 5.1 and 5.4) passRelated
DAW/daw-modul-berhtjan-core#21, DAW/daw-contracts#17
Implemented on main
Commits:
bbb159cPushed. Follow-up points, if any, are tracked in their own issues.