Skip to content

Preserve unmodeled fields when editing K8s endpoint aggregators - #1345

Draft
ikhoon wants to merge 1 commit into
line:mainfrom
ikhoon:fix-k8s-aggregator-editor-distinct
Draft

Preserve unmodeled fields when editing K8s endpoint aggregators#1345
ikhoon wants to merge 1 commit into
line:mainfrom
ikhoon:fix-k8s-aggregator-editor-distinct

Conversation

@ikhoon

@ikhoon ikhoon commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Motivation:

The xDS Kubernetes endpoint aggregator editor rebuilds the aggregator YAML from its form model on every save. Because the form modeled only a subset of the schema, saving from the console silently dropped every field the form has no editor for — distinctEndpoint, metadataMapping, and the aggregator-level policy today, and any field added to the schema later. An operator who edited an aggregator through the console would unknowingly discard them; losing distinctEndpoint, for example, re-introduces duplicate endpoints on the next rolling restart.

Modifications:

  • Add distinctEndpoint to the watcher form as a checkbox next to "Trust certificates".
  • On update, overlay the form's edits onto the document the form was loaded from instead of rebuilding it from scratch. Fields the form owns come from the form (an emptied optional field is dropped — an intentional clear), and any field the form does not model is preserved verbatim. This closes the whole class of silent drops: a field added to the proto later survives an edit with no change here.
  • Carry the loaded document — per watcher and at the aggregator level — through the form so the overlay has the original to merge onto. A newly-added watcher or a new aggregator has none, so creation is unaffected.
  • Show a read-only note with the number of configured metadata-mapping rules, since the form has no editor for them.

Result:

Editing a Kubernetes endpoint aggregator through the web console no longer drops fields the form has no editor for, including fields added to the schema later. distinctEndpoint is now viewable and editable in the form.

Testing:

  • Component tests (jest + @testing-library/react) covering load → edit → save round-trips: distinctEndpoint on/off, a multi-watcher removal that keeps each mapping with its own watcher, that a field the form does not model survives an update, and that an emptied optional field is still cleared. The "unmodeled field survives" test was confirmed failing before this change and passing after.
  • Verified live in the web console against a local test server, in light and dark mode: the "Distinct endpoint" checkbox reflects the stored value, and the read-only metadata-mapping note appears only when mappings exist.

Screenshots (web console, light / dark):

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The Kubernetes aggregator editor preserves unmanaged watcher and aggregator YAML fields across load/save operations. It adds a distinct endpoint checkbox, displays preserved metadata mapping counts, and tests round-trip serialization, watcher isolation, and optional-field clearing.

Changes

xDS aggregator preservation

Layer / File(s) Summary
Round-trip model and YAML handling
webapp/src/dogma/features/xds/K8sAggregatorEditor.tsx
Form state and YAML serialization retain watcher distinctEndpoint, unmanaged watcher fields, and aggregator-level fields such as policy.
Watcher editor controls and indicators
webapp/src/dogma/features/xds/K8sAggregatorEditor.tsx
The watcher editor adds a distinct endpoint checkbox and conditionally displays preserved metadata mapping counts.
Round-trip and watcher isolation tests
webapp/tests/dogma/features/xds/K8sAggregatorEditor.test.tsx
Tests cover preservation, toggling, policy omission, per-watcher mappings, conditional UI messages, future fields, and optional-field clearing.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant YAML
  participant K8sAggregatorEditor
  participant Form
  participant UpdateMutation
  YAML->>K8sAggregatorEditor: Load watcher and aggregator fields
  K8sAggregatorEditor->>Form: Populate managed values and original YAML entries
  Form->>K8sAggregatorEditor: Submit edited values
  K8sAggregatorEditor->>UpdateMutation: Send overlaid YAML
  UpdateMutation->>YAML: Persist updated and preserved fields
Loading

Possibly related PRs

Suggested labels: new feature

Suggested reviewers: jrhee17, minwoox

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the primary change: preserving fields not directly modeled by the Kubernetes endpoint aggregator editor.
Description check ✅ Passed The description directly explains the motivation, implementation, behavior, and testing for preserving unmodeled aggregator and watcher fields.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
webapp/src/dogma/features/xds/K8sAggregatorEditor.tsx (1)

83-117: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Clarify the round-trip contract for MetadataMappingForm.

The fields are only passed through as watcher.metadataMapping on load/save, so this interface does not validate the persisted schema; if those shapes are a documented Central Dogma xDS convention, cite or move the contract to the backend/proto definition to prevent future UI changes from silently dropping or reformatting unsupported mappings.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@webapp/src/dogma/features/xds/K8sAggregatorEditor.tsx` around lines 83 - 117,
Clarify the round-trip contract represented by MetadataMappingForm: reference
the authoritative Central Dogma xDS backend or proto schema if one exists, or
move the mapping type definition there and reuse it in K8sAggregatorEditor.
Ensure parseToFormData and buildBody continue preserving all supported
metadataMapping fields without silently dropping or reformatting unknown values.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@webapp/src/dogma/features/xds/K8sAggregatorEditor.tsx`:
- Around line 83-117: Clarify the round-trip contract represented by
MetadataMappingForm: reference the authoritative Central Dogma xDS backend or
proto schema if one exists, or move the mapping type definition there and reuse
it in K8sAggregatorEditor. Ensure parseToFormData and buildBody continue
preserving all supported metadataMapping fields without silently dropping or
reformatting unknown values.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 061031ec-a7a2-46eb-9590-f40dbc9e5f0f

📥 Commits

Reviewing files that changed from the base of the PR and between 5afa110 and 33eb336.

📒 Files selected for processing (2)
  • webapp/src/dogma/features/xds/K8sAggregatorEditor.tsx
  • webapp/tests/dogma/features/xds/K8sAggregatorEditor.test.tsx

Motivation:
The xDS Kubernetes endpoint aggregator editor rebuilds the aggregator YAML from its form
model on every save. Because the form modeled only a subset of the schema, saving from the
console silently dropped every field the form has no editor for - distinctEndpoint,
metadataMapping, and the aggregator-level policy today, and any field added to the schema
later. An operator who edited an aggregator through the console would unknowingly discard
them; losing distinctEndpoint, for example, re-introduces duplicate endpoints on the next
rolling restart.

Modifications:
- Add distinctEndpoint to the watcher form as a checkbox next to "Trust certificates".
- On update, overlay the form's edits onto the document the form was loaded from instead of
  rebuilding it from scratch. Fields the form owns come from the form (an emptied optional
  field is dropped, i.e. an intentional clear), and any field the form does not model is
  preserved verbatim. This closes the whole class of silent drops: a field added to the
  proto later survives an edit with no change here.
- Carry the loaded document, per watcher and at the aggregator level, through the form so the
  overlay has the original to merge onto. A newly-added watcher or a new aggregator has none,
  so creation is unaffected.
- Show a read-only note with the number of configured metadata-mapping rules, since the form
  has no editor for them.
- Add tests: distinctEndpoint on/off, a multi-watcher removal that keeps each mapping with its
  own watcher, that an unmodeled field survives an update, and that an emptied optional field
  is still cleared.

Result:
Editing a Kubernetes endpoint aggregator through the web console no longer drops fields the
form has no editor for, including fields added to the schema later. distinctEndpoint is now
viewable and editable in the form.
@ikhoon
ikhoon force-pushed the fix-k8s-aggregator-editor-distinct branch from 33eb336 to 9258fbc Compare July 30, 2026 16:34
@ikhoon ikhoon changed the title Preserve distinctEndpoint and metadataMapping when editing K8s endpoint aggregators Preserve unmodeled fields when editing K8s endpoint aggregators Jul 31, 2026
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.

1 participant