Skip to content

fix #595: PublishedODataService EntityTypePointer wired by qualified entity name#596

Open
ako wants to merge 1 commit into
mainfrom
fix/595-published-odata-entitytypepointer
Open

fix #595: PublishedODataService EntityTypePointer wired by qualified entity name#596
ako wants to merge 1 commit into
mainfrom
fix/595-published-odata-entitytypepointer

Conversation

@ako
Copy link
Copy Markdown
Collaborator

@ako ako commented May 23, 2026

Summary

Fixes #595. serializePublishedODataService keyed entityTypeIDMap by et.ExposedName (e.g. "Customers") but looked it up by es.EntityTypeName (e.g. "OdTest.Customer"). The lookup always returned an empty string, so EntityTypePointer was never written on ODataPublish$EntitySet BSON. Studio Pro's EntitySet.Check then NREs dereferencing the missing pointer and aborts the entire background project checker.

One-line fix in sdk/mpr/writer_odata.go: key the map by et.Entity to match what astEntityDefToModel stores on the entity set.

Why the test missed this

TestSerializePublishedODataService checked all the EntitySet's own fields (ExposedName, UsePaging, ReadMode, etc.) but never the cross-reference back to the EntityType. The PR adds that assertion. It also switches the test entity-type BaseElement.ID from the placeholder "et-1" to a real UUID so idToBsonBinary doesn't silently fall back to random IDs, making the pointer comparison meaningful.

Test plan

  • New unit assertion fails without the fix:
    writer_odata_test.go:294: EntityTypePointer: expected primitive.Binary, got <nil> (<nil>)
    
  • After the fix:
    --- PASS: TestSerializePublishedODataService (0.00s)
    
  • make test — all packages pass
  • make lint — Go + TypeScript pass
  • ./bin/mxcli check mdl-examples/bug-tests/595-published-odata-entitytypepointer.mdl✓ Syntax OK (3 statements)
  • Manual validation in Studio Pro (user): apply the bug-test MDL to a project, open in Studio Pro, confirm no NullReferenceException in EntitySet.Check and the project checker emits real problems normally

Related

🤖 Generated with Claude Code

`serializePublishedODataService` keyed `entityTypeIDMap` by
`et.ExposedName` (e.g. "Customers") but looked it up by
`es.EntityTypeName` (e.g. "OdTest.Customer"). The two values are
different, so the lookup always returned an empty string and the
`if entityTypeID != ""` guard in `serializePublishedEntitySet` meant
`EntityTypePointer` was never written.

Without that pointer, Studio Pro's `EntitySet.Check` can't navigate
from a set to its type, NREs on the missing reference, and aborts the
entire background project checker — hiding all other problems in the
project, not just the published OData service.

Key the map by `et.Entity` (the qualified entity name), matching how
`EntityTypeName` is populated on `PublishedEntitySet` in
`astEntityDefToModel`.

Extend `TestSerializePublishedODataService` to assert
`EntityTypePointer` matches the corresponding EntityType's `$ID`. The
prior test covered other fields but not this pointer, which is why the
bug landed undetected — the existing assertions only checked the
EntitySet's own fields, never the cross-reference.

Add `mdl-examples/bug-tests/595-published-odata-entitytypepointer.mdl`
as the end-to-end fixture: applying it to a project must yield a
project that opens in Studio Pro without the `EntitySet.Check` NRE.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

AI Code Review

Review Summary

Critical Issues

None found.

Moderate Issues

None found.

Minor Issues

None found.

What Looks Good

  • Correct Root Cause Fix: The one-line change in sdk/mpr/writer_odata.go correctly keys the entityTypeIDMap by et.Entity (qualified name) to match the lookup key (es.EntityTypeName), resolving the NRE in Studio Pro's EntitySet.Check.
  • Test Improvements:
    • Updated test uses a real UUID for BaseElement.ID instead of placeholder "et-1", making pointer comparisons meaningful.
    • Added critical assertion for EntityTypePointer that was missing in the original test, catching the bug.
    • Test plan confirms the fix resolves both unit test failure and manual validation in Studio Pro.
  • Bug Test Fixture: The new MDL script in mdl-examples/bug-tests/595-published-odata-entitytypepointer.mdl is well-documented and provides an end-to-end reproduction case.
  • Atomic Scope: PR addresses only issue PublishedODataService EntityTypePointer never set — Studio Pro NRE in EntitySet.Check #595 with focused changes (fix + test improvements + bug test).
  • No MDL Syntax Changes: Since this is a pure bug fix without MDL syntax modifications, syntax design and full-stack consistency checks are not applicable.
  • Quality: Changes are clean, well-commented, and follow existing patterns. No duplication or overlap detected.

Recommendation

Approve the PR. The fix is correct, tests are improved, and the bug test fixture is properly added. All validation checks pass. No changes needed.


Automated review via OpenRouter (Nemotron Super 120B) — workflow source

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PublishedODataService EntityTypePointer never set — Studio Pro NRE in EntitySet.Check

1 participant