You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ossie.apache.org by "christianeu-db (via GitHub)" <gi...@apache.org> on 2026/10/06 19:39:34 UTC

[I] Python SDK silently drops unknown keys on nested objects that `ossie validate` rejects [ossie]

christianeu-db opened a new issue, #530:
URL: https://github.com/apache/ossie/issues/530

   ## Summary
   
   The JSON Schema sets `additionalProperties: false` on every object. The SDK sets `extra="forbid"` only on the root `OssieDocument`; nested models (`OssieField`, `OssieDataset`, `OssieMetric`, `OssieRelationship`, `OssieSemanticModel`) inherit pydantic's default `extra="ignore"`. So an unknown or mistyped key on a nested object passes `OssieDocument.model_validate(...)` and is dropped on serialization, while `ossie validate` rejects the same document.
   
   ## Reproduction
   
   `t_nested.yaml` with two typos — `descriptionn` on a field, `expresssion` on a metric:
   
   ```yaml
   version: 0.2.0.dev0
   name: sales
   datasets:
     - name: orders
       source: db.schema.orders
       fields:
         - name: amount
           descriptionn: "typo: should be 'description'"
           expression:
             dialects:
               - { dialect: ANSI_SQL, expression: amount }
   metrics:
     - name: total_amount
       expresssion:            # typo: should be 'expression'
         dialects:
           - { dialect: ANSI_SQL, expression: SUM(amount) }
       expression:
         dialects:
           - { dialect: ANSI_SQL, expression: SUM(amount) }
   ```
   
   SDK — `OssieDocument.model_validate(...)` then `to_ossie_yaml()`:
   
   ```
   model_validate: ACCEPTED (no error raised)
   field keys after round-trip : ['expression', 'name']   # 'descriptionn' dropped
   metric keys after round-trip: ['expression', 'name']   # 'expresssion' dropped
   ```
   
   Validator — `python validation/validate.py t_nested.yaml`:
   
   ```
   Validation FAILED with 2 error(s):
     [Schema] datasets -> 0 -> fields -> 0: Additional properties are not allowed ('descriptionn' was unexpected)
     [Schema] metrics -> 0: Additional properties are not allowed ('expresssion' was unexpected)
   ```
   
   ## Root cause
   
   In `python/src/ossie/models.py`, `OssieDocument` sets `extra="forbid"`; nested models set only `frozen=True` and inherit `extra="ignore"` — `OssieField`, `OssieDataset`, `OssieMetric`, `OssieRelationship, `OssieSemanticModel`.
   
   The schema (`core-spec/ossie-schema.json`) sets `additionalProperties: false` on every object. Its one exception is the AI-context object (line 76, `true`), which the SDK matches with `extra="allow"`. That is the only place schema and SDK agree; everywhere else the schema forbids unknown keys and the SDK ignores them.
   
   ## Why this is a design question, not an obvious fix
   
   `test_only_document_rejects_extra_fields` encodes that an embedded `OssieSemanticModel` tolerates an extra key while the root rejects it — so the root-level asymmetry is intentional. But that test only exercises a root/parent-level key. The nested-object case above is untested, and is where the SDK diverges from both the schema and the validator.
   
   ## Proposed resolution
   
   Pick one:
   
   1. **(Recommended) Align the SDK with the schema** - set `extra="forbid"` on the nested models. Closes the data-loss gap and makes both tools agree. Behavior change for any caller relying on nested keys being dropped.
   2. **Document the asymmetry** - keep the SDK permissive, but say so in the SDK docs and `OssieDocument`'s docstring, and extend the test above to pin the nested behavior as intended.
   
   


-- 
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.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Python SDK silently drops unknown keys on nested objects that `ossie validate` rejects [ossie]

Posted by "jbonofre (via GitHub)" <gi...@apache.org>.
jbonofre closed issue #530: Python SDK silently drops unknown keys on nested objects that `ossie validate` rejects
URL: https://github.com/apache/ossie/issues/530


-- 
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