Skip to content

fix(client): keep cache tags on pointer-slice envelopes and renamed stream entities - #133

Merged
juicycleff merged 1 commit into
mainfrom
fix/client-nullable-enum-null
Nov 20, 2026
Merged

juicycleff merged 1 commit into
mainfrom
fix/client-nullable-enum-null

Conversation

@juicycleff

Copy link
Copy Markdown
Contributor

Two ways a generated TypeScript client silently lost its cache contract, so a write or a live event refreshed nothing and pages stayed stale until a reload. Both were found in Loomplane's dashboard, where they disabled list invalidation across most of its Cloud screens.

Pointer-slice envelopes provided no tags

A Go []*T reaches the OpenAPI document as array items of oneOf: [$ref T, {type: object, nullable: true, enum: [null]}], the OpenAPI 3.0 null idiom the router writes itself. compositionTarget skipped only members with type: "null", so the null member read as an unnamed type and the whole envelope as a wrapper around nothing: no entity, no rootType, no provides. Every x-forge-envelope over a pointer slice was affected, declared or inferred, and mutations invalidating T[] reached no query.

isNullSchema now recognizes both spellings, as the TypeScript and Dart codec generators already did. In Loomplane this brought 12 declared envelopes back (PlanningCloudList, CloudTargetList, CloudSyncList, PoolList, ServerList, ZoneList, OperationList and others), plus several inferred ones. The generator's warning for these blamed "an inline object", which hid the cause.

Stream bindings kept the bare type name

resolveStreamEntityNames renames a binding's entity to the component the document actually holds, matching on x-forge-type. It ran per source. A type renamed only in the OpenAPI document, because it collides there and not in the AsyncAPI one, kept its bare name in the binding: frames upserted Target:7 while every REST read held CloudprofilesTarget:7, so live updates never reached the screen. Loomplane hit this for Target, Deployment and Source.

MergeSpecs now re-resolves stream bindings against the merged schemas. It copies the bindings first, so the source specs are not mutated.

Tests

  • TestEnvelopeOverPointerSliceProvidesCollectionTag (declared and inferred) fails without the fix and passes with it; TestNullableEnumWithValuesIsNotNull guards the boundary.
  • TestMergeSpecsRenamesStreamEntityToRESTComponent covers the rename and checks the source binding is untouched.
  • go test ./internal/client/ passes. internal/client/generators/typescript has tsc-dependent tests that fail in a checkout without its node toolchain; they fail identically on main there.
  • Regenerated Loomplane's client with a CLI built from this branch: warnings drop from 25 to 13, the dashboard typechecks, and its new cache-contract test (every invalidated tag is carried by some query) passes.

…tream entities

Two ways a generated client lost its cache contract without failing:

- A Go `[]*T` reaches the document as items of `oneOf: [$ref T, {type:
  object, nullable: true, enum: [null]}]`, the OpenAPI 3.0 null idiom the
  router writes itself. compositionTarget only skipped `type: "null"`, so the
  null member read as an unnamed type and every pointer-slice envelope
  provided no tags. isNullSchema recognizes both spellings, as the codec
  generators already did.

- resolveStreamEntityNames ran per source. A type renamed only in the
  OpenAPI document (it collides there, not in the AsyncAPI one) kept its bare
  name in the stream binding, so frames upserted `Target:7` while REST reads
  held `CloudprofilesTarget:7`. MergeSpecs now re-resolves bindings against
  the merged schemas.
@vercel

vercel Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
forge Ready Ready Preview Nov 20, 2026 10:40pm UTC

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

Conventional Commits Validation

PR Title: valid
Commits: all 1 follow conventional format

@codecov

codecov Bot commented Nov 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 78.78788% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/client/merge.go 80.00% 4 Missing and 1 partial ⚠️
internal/client/entity_fields.go 75.00% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@juicycleff
juicycleff merged commit be91306 into main Nov 20, 2026
45 checks passed
@juicycleff
juicycleff deleted the fix/client-nullable-enum-null branch November 20, 2026 23:02
juicycleff added a commit that referenced this pull request Nov 20, 2026
cmd/forge v1.14.2 still required the root module at a pseudo-version from
before the release, so `go install github.com/xraph/forge/cmd/forge@v1.14.2`
built the client generator without #133: pointer-slice envelopes lost their
cache tags and stream entities kept their bare names. The root module's
v1.14.2 has the fix; the CLI just didn't use it.

This branch was successfully deployed

1 active deployment
Preview — dc2b2187 Deployed Nov 20, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant