Skip to content

fix(avro): write declared types with their full Avro name - #296

Open
radhikaa06 wants to merge 1 commit into
accordproject:mainfrom
radhikaa06:fix/avro-imported-type-names
Open

radhikaa06 wants to merge 1 commit into
accordproject:mainfrom
radhikaa06:fix/avro-imported-type-names

Conversation

@radhikaa06

Copy link
Copy Markdown
Contributor

Closes #295

Changes

  • visitField now passes the fully qualified type, without its namespace version, to toAvroType for fields and for map values. It uses ModelUtil.removeNamespaceVersionFromFullyQualifiedName, the same call the OData visitor makes. toAvroType itself is unchanged.
  • Removed the last Avro skip, on hr_integration. All 8 Avro verification cases now compile with avro-tools 1.12.0.
  • Added a unit test with an imported concept, an enum array and a map whose value is imported. It fails on main, and also fails if only the map line is reverted.
  • Updated the 19 Avro lines in the snapshot.

Flags

  • Types in the file's own namespace are written fully qualified too, for example org.acme.hr.Employee inside @namespace("org.acme.hr"). That is valid Avro and matches what OData does, but it changes every non-primitive reference in the snapshot. If you'd rather keep short names for same-namespace types, I can qualify only the ones from another namespace.
  • The leading-underscore follow-up from bug: Avro IDL generated from a versioned namespace fails avro-tools #289 (_identifier, _timestamp) is not in this PR. It needs a different change, so I'll send it separately.
  • Locally npm test misses the branch coverage gate at 95.91%, the same number as main on my machine. CI passed on fix(avro): drop the version from Avro namespaces #290 with the same setup.

Screenshots or Video

Before:
before

After:
after

Related Issues

Author Checklist

  • Ensure you provide a DCO sign-off for your commits using the --signoff option of git commit.
  • Vital features and changes captured in unit and/or integration tests
  • Commits messages follow AP format
  • Extend the documentation, if necessary
  • Merging to main from radhikaa06:fix/avro-imported-type-names

The visitor wrote non-primitive types by their short name, so a type
imported from another namespace was resolved against the current
@namespace and avro-tools failed with "Undefined schema". Write the
namespace (without its version) and short name for fields and map
values, and run the hr_integration Avro case that this unblocks.

Signed-off-by: radhika agarwal <theradhika2410@gmail.com>
@mira-accord-project

Copy link
Copy Markdown

Thanks for the PR and for the detailed report in #295. Writing declared types with their full Avro name is a useful fix. A maintainer will review it, and their feedback will appear here. Sorry for the wait so far.

Drafted by an Accord Project agent, reviewed by a maintainer.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified for the change to emit fully qualified, version-free Avro type references.

No open issues 🎉

What changed in this PR

Fixes #295 by emitting fully qualified, version-free Avro type names so imported declarations resolve correctly. This extends the namespace fix from #290 to field types and map values.

Changes:

  • Qualifies declared type references while leaving primitive conversion unchanged.
  • Adds regression coverage for an imported concept, enum array, and enum map value.
  • Enables the remaining Avro verification case and updates expected snapshots.
File Description
test/​verification/​cases.js Removes the Avro skip for hr_integration.
test/​codegen/​fromcto/​avro/​avrovisitor.js Tests fully qualified imported type references.
test/​codegen/​__snapshots__/​codegen.js.snap Updates expected Avro output to use qualified names.
lib/​codegen/​fromcto/​avro/​avrovisitor.js Uses version-free, fully qualified names for fields and map values.

Review effort: Balanced

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Avro IDL references imported types by short name, so avro-tools cannot resolve them

2 participants