Repository navigation
cligen: omit immutable (create-only) fields from update-command flags - #7309
Open
janniklasrose wants to merge 3 commits into
Open
janniklasrose wants to merge 3 commits into
janniklasrose wants to merge 3 commits into
Conversation
An IMMUTABLE (AIP-203), non-computed request-body field is settable at create but cannot change on update. Such fields now keep their CLI flag on create-type commands (and any non-update command) and are omitted from update-type commands. Computed/output-only fields are unchanged and stay flagless everywhere, so a field that is both immutable and computed (e.g. dashboards parent_path) is unaffected. This wires the IMMUTABLE behavior and the update-crud signal from cli.json into the render model: - internal/clijson/types.go: FieldJSON.IsImmutable, MethodJSON.IsCrudUpdate (regenerated verbatim from the genkit contract). - transform.go / model.go: propagate both into the CLI render model. - templates/service.go.tmpl: skip immutable, non-computed fields on update-type methods in both the flag-declaration and well-known-type parse loops. Depends on the matching genkit change (deco/genkit/rendering/cli) landing in universe so a future generate-clijson emits is_immutable/is_crud_update. Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
Collaborator
Integration test reportCommit: 88fb3cc
Top 6 slowest tests (at least 2 minutes):
|
The template change alone has no effect on any existing command (cli.json does not carry the new keys yet), so the user-visible entry belongs with the regeneration that removes flags. Co-authored-by: Isaac <no-reply@databricks.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
Teach the CLI command generator that an IMMUTABLE request-body field (AIP-203: settable at create, cannot change on update) keeps its
--flagon create-type commands but is omitted from update-type commands. Computed/output-only fields are untouched and stay flagless everywhere.This is the CLI half of a two-part change; the other half is the genkit PR databricks-eng/universe#2777642.
How the two PRs fit together
codelayer into the commands block ofcli.json:FieldJSON.is_immutable(frombehaviors: [IMMUTABLE]) andMethodJSON.is_crud_update(fromx-databricks-crud: update).internal/clijson/types.go, regenerated from the genkit contract), propagate them into the render model, and skip the flag inservice.go.tmplwhen.IsImmutable && $method.IsCrudUpdate. The new branch sits after the.IsComputed/.IsOutputOnlybranches, so computed fields keep today's behaviour..codegen/_openapi_shapast the genkit change, run./task generate-clijson+generate-cligen. Only then do the keys appear incli.jsonand the stubs change.Ordering:
./task generate-clijsonbuilds genkit from source at_openapi_sha, so the regeneratedcli.jsonis reproducible only once the genkit change is on universe master and the SHA is bumped past it. This PR is deliberately logic only — nocli.json/stub changes — and is inert against today'scli.json(the keys are absent, so nothing is skipped). It can merge before or after the genkit PR; the regen must come last.Why
Motivated by #5983 (
databricks lakeview create --parent-pathdisappeared). Root cause there is thatDashboard.parent_pathis annotatedcomputed: truein the proto (a separate proto fix is needed for that field; see the issue). While investigating, it turned out cligen has no notion of immutability at all: immutable fields either get a flag on both create and update, or (if also computed) on neither. This PR adds the missing create-only case so that, onceparent_pathdropscomputed, it comes back oncreatebut not onupdate— and fixes the same thing for every other immutable field today.Impact once regenerated (measured)
Joint test at current universe master (
e4c1445cc07c3, the rebased head of #2777642): built//deco/genkitand//openapi:all-internal.jsonfrom that branch, rangenkit update-sdkagainst this checkout, thengenerate-cligen. The regeneratedcli.jsongains 826is_immutableand 193is_crud_updatekeys, and 15 flags disappear from 11update-*commands across 6 services; nocreateflag changes andlakeviewis untouched (itsparent_pathis stillcomputed):account disaster-recovery update-failover-group--nameagent-kit update-memory--session-id,--source-typeagent-kit update-memory-store--display-nameagent-kit update-session--parent-session-idai-gateway update-mcp-service/update-model-provider-service/update-model-service/update-skill--namedomains update-domain--name,--parent-domain-idenvironments update-default-workspace-base-environment--namefeature-engineering update-feature--filter-conditionfeature-engineering update-materialization-set--materialization-set-idfeature-engineering update-materialized-feature--materialized-feature-idControl: stripping the two new keys from that same
cli.json(jq 'del(.. | .is_immutable?, .is_crud_update?)') and re-rendering leaves only an unrelatedinstance-poolsdoc-string change from spec drift — so the removals above are entirely attributable to the new keys. The regenerated stubs compile (go build ./cmd/...).These flags were non-functional (the API rejects changing an immutable field), but their removal is user-visible (
unknown flag), hence the.nextchanges/clientry. The rule keys strictly offx-databricks-crud: update; e.g.BundleDeployments.UpdateOperationdescribes itself as an update but isn't annotated, so its flags are unchanged.Why the changes are safe
go build ./...andgo test ./internal/cligen ./internal/clijsonpass on the rebased branch.go run ./internal/cligen --input .codegen/cli.json --output .against main's currentcli.jsonproduces no diff — the template change is a no-op until the keys exist.Tests
Unit tests above; the measurable behaviour change (stub diff) is verified by the joint regeneration and will be committed in the follow-up regen PR once
_openapi_shacan be bumped past the genkit change.This pull request and its description were written by Isaac.