You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ossie.apache.org by "ayushtkn (via GitHub)" <gi...@apache.org> on 2026/10/10 19:20:56 UTC
[PR] fix(python): accept only booleans for is_time, as the schema does [ossie]
ayushtkn opened a new pull request, #557:
URL: https://github.com/apache/ossie/pull/557
## Summary
`ossie-schema.json` types `$defs.Dimension.properties.is_time` as `"boolean"`, but the
field was a plain `Optional[bool]`, so pydantic's lax mode accepted ten values the
schema forbids:
"yes" "true" "True" "no" "off" "1" 1 0 1.0 0.0
The harm is not bad output — it's a lost diagnostic. Coercion stores a real boolean, so
the invalid input is rewritten into valid output and the mistake disappears:
in='yes' -> stored True -> serialized {"is_time": true} -> schema accepts output: True
schema accepts the INPUT 'yes': False
A document written with `is_time: "no"` is wrong per the spec, and the SDK is the only
place that could say so. It instead turns it into `false` and a later schema check passes.
`StrictBool` narrows the field to the two values the schema permits.
`is_time` is the only `"type": "boolean"` in the schema and the only `bool` field in the
SDK, so this is the whole of the change.
## Related Issues
<!-- Link any related GitHub issues: Closes #123, Fixes #456 -->
## Checklist
### Specification
- [ ] Spec changes are included in `core-spec/` and follow the existing structure
- [ ] Spec changes have been discussed on the mailing list or in a linked issue
- [ ] Breaking changes to the spec are clearly called out in the summary
### Ontology
- [ ] Ontology changes in `ontology/` are consistent with spec changes
- [ ] New or modified terms are defined and documented
### Converters
- [ ] Converter logic in `converters/` is updated to reflect spec or ontology changes
- [ ] New converters include tests under the converter's test directory
- [ ] If adding a new converter, `.github/labeler.yml` is updated with the new path
### Validation
- [ ] Validation rules in `validation/` are updated if the spec changed
- [ ] New validation cases are covered by tests
### Documentation
- [ ] `docs/` is updated to reflect any user-facing changes
- [ ] New features or behaviors are documented with examples where appropriate
- [ ] `CONTRIBUTING.md` is updated if the contribution process changed
### Examples
- [ ] `examples/` are added or updated for any new spec constructs or converter support
### Tests
- [ ] All existing tests pass (`pytest` / CI green)
- [ ] New functionality is covered by tests
### Compliance
- [ ] ASF license headers are present on all new source files
- [ ] No third-party dependencies are added without PMC/IPMC approval
- [ ] If third-party source code is vendored/copied (not just declared as a dependency), `NOTICE` and/or `LICENSE` have been updated per [ASF policy](https://infra.apache.org/licensing-howto.html)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ossie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(python): accept only booleans for is_time, as the schema does [ossie]
Posted by "jbonofre (via GitHub)" <gi...@apache.org>.
jbonofre merged PR #557:
URL: https://github.com/apache/ossie/pull/557
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ossie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(python): accept only booleans for is_time, as the schema does [ossie]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #557:
URL: https://github.com/apache/ossie/pull/557#discussion_r4238894681
##########
python/src/ossie/models.py:
##########
@@ -123,7 +123,11 @@ class OssieDimension(BaseModel):
model_config = ConfigDict(frozen=True, extra="forbid")
- is_time: Optional[bool] = None
+ # The schema types this `boolean`, which admits only true and false. A plain
+ # `bool` would let pydantic's lax mode accept "yes", "1", 1 or 1.0 and store a
+ # real boolean, so input the schema forbids is silently rewritten into output it
+ # allows, and the mistake is never reported.
+ is_time: Optional[StrictBool] = None
Review Comment:
`Optional[StrictBool]` still accepts an explicit `None`, so `model_validate({"is_time": None})` succeeds even though the schema permits omission but not `null`. Serialization then excludes the value, causing the same lost diagnostic this change is intended to prevent. Please distinguish a missing key from an explicit null (for example, with a pre-validation check or a non-null field annotation with an omission default) and add a rejection test for `None`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ossie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(python): accept only booleans for is_time, as the schema does [ossie]
Posted by "ayushtkn (via GitHub)" <gi...@apache.org>.
ayushtkn commented on code in PR #557:
URL: https://github.com/apache/ossie/pull/557#discussion_r4238907710
##########
python/src/ossie/models.py:
##########
@@ -123,7 +123,11 @@ class OssieDimension(BaseModel):
model_config = ConfigDict(frozen=True, extra="forbid")
- is_time: Optional[bool] = None
+ # The schema types this `boolean`, which admits only true and false. A plain
+ # `bool` would let pydantic's lax mode accept "yes", "1", 1 or 1.0 and store a
+ # real boolean, so input the schema forbids is silently rewritten into output it
+ # allows, and the mistake is never reported.
+ is_time: Optional[StrictBool] = None
Review Comment:
Correct on the mechanics, and the laundering is the same shape: {"is_time": null} is schema-invalid, the model accepts it, and exclude_none=True drops the key so the output validates.
I'd rather not fix it in this PR, because it isn't specific to is_time. ossie-schema.json permits null for no property anywhere, and all 27 Optional[...] fields in the SDK accept an explicit null and serialize it away — OssieField.model_validate({..., "label": None, "description": None, "datatype": None}) succeeds today and emits a document with those keys simply absent.
The two problems differ in kind. Lax coercion is per-field and per-type, and StrictBool fixes it; this PR applies that to the only "type": "boolean" in the schema. Explicit-null acceptance follows from Optional[X] = None being how pydantic spells "optional", so it is uniform across the models by construction. Patching it on is_time alone would leave the other 26 unchanged and introduce a one-off idiom the next reader would reasonably question.
Doing it properly means deciding whether the SDK distinguishes an absent key from an explicit null across all 10 models — a behaviour change for any caller currently passing label=None. Nothing in this repository does (I checked every Ossie*(...) construction), but that is a decision worth its own PR and review rather than a rider on this one. I'll open it as a follow-up unless a reviewer would rather keep absent and null interchangeable.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ossie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org