Skip to content

fix(dbt): serialize osi-to-msi manifest with pydantic v1 .json() - #331

Open
ntoxlut wants to merge 1 commit into
apache:mainfrom
ntoxlut:fix/dbt-osi-to-msi-json-serialize
Open

fix(dbt): serialize osi-to-msi manifest with pydantic v1 .json()#331
ntoxlut wants to merge 1 commit into
apache:mainfrom
ntoxlut:fix/dbt-osi-to-msi-json-serialize

Conversation

@ntoxlut

@ntoxlut ntoxlut commented Aug 18, 2026

Copy link
Copy Markdown

Summary

ossie-dbt osi-to-msi fails on every input, including the repository's own
examples/tpcds_semantic_model.yaml, with:

AttributeError: 'PydanticSemanticManifest' object has no attribute 'model_dump_json'

PydanticSemanticManifest (from metricflow_semantic_interfaces) subclasses
pydantic.v1.BaseModel, whose JSON serializer is .json(), not the pydantic v2
.model_dump_json(). The conversion itself works — only the CLI's write step
was calling a v2-only method on a v1 object.

Fix

  • cli.py: use .json(by_alias=True, exclude_none=True, indent=2), which takes
    the same options on a pydantic v1 model and produces valid output.
  • Add tests/test_cli.py — an end-to-end test that drives osi-to-msi and
    asserts a valid semantic manifest is written. No test covered the CLI before,
    which is why CI stayed green through the crash.

Verification

cd converters/dbt
uv run pytest          # 100 passed (was 99)
uv run ossie-dbt osi-to-msi -i ../../examples/tpcds_semantic_model.yaml -o /tmp/manifest.json
# -> Written to /tmp/manifest.json  (valid JSON)

The new test fails without the fix (AttributeError) and passes with it.

Related Issues

Fixes #296

Checklist

Specification

N/A — bug fix only, no spec change.

Ontology

N/A — no ontology change.

Converters

  • New converters include tests under the converter's test directory

Validation

N/A — no validation change.

Documentation

N/A — no user-facing behavior change beyond the command no longer crashing.

Examples

N/A — no 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
The osi-to-msi CLI called .model_dump_json() on the converter output,
but PydanticSemanticManifest (from metricflow_semantic_interfaces)
subclasses pydantic.v1.BaseModel, whose serializer is .json(). As a
result osi-to-msi raised AttributeError on every input, including the
repository's own examples/tpcds_semantic_model.yaml.

Switch to .json(by_alias=True, exclude_none=True, indent=2), which
produces identical serialization options on a pydantic v1 model, and
add an end-to-end CLI test that drives osi-to-msi and asserts the
output is a valid semantic manifest. No test covered the CLI before,
so CI did not catch the crash.

Fixes apache#296

Signed-off-by: Ntokozo Luthuli <ntokozomshibe@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant