Skip to content

fix: comment status without SSA options#660

Open
fernandezcuesta wants to merge 1 commit into
crossplane:mainfrom
fernandezcuesta:fix/observation-ssa-markers
Open

fix: comment status without SSA options#660
fernandezcuesta wants to merge 1 commit into
crossplane:mainfrom
fernandezcuesta:fix/observation-ssa-markers

Conversation

@fernandezcuesta
Copy link
Copy Markdown
Contributor

@fernandezcuesta fernandezcuesta commented May 21, 2026

Description of your changes

Remove SSA markers and injected key defaults in the observation (status) fields.

Fixes #659

I have:

  • Read and followed Upjet's contribution process.
  • Run make reviewable to ensure this PR is ready for review.
  • Added backport release-x.y labels to auto-backport this PR if necessary.

How has this code been tested

Added a test.

Real e2e test WIP (testing with provider-pageduty), if needed.

Signed-off-by: Jesús Fernández <7312236+fernandezcuesta@users.noreply.github.com>
@fernandezcuesta fernandezcuesta marked this pull request as ready for review May 22, 2026 11:09
@fernandezcuesta fernandezcuesta changed the title fix: comment status without ssa options fix: comment status without SSA options May 22, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 22, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

The PR fixes a bug where server-side apply merge-strategy markers were incorrectly applied to Observation struct fields. When status lists contained multiple items, the API server rejected updates due to conflicting default values. The fix strips SSA markers and defaults from Observation fields, with test coverage validating that markers appear only in the Spec side (Parameters) but not in the Status side (Observation).

Changes

SSA Marker Removal and Test Coverage

Layer / File(s) Summary
Strip SSA markers from Observation fields
pkg/types/field.go
When adding a field to the Observation type, the code now clears ServerSideApplyOptions, removes KubebuilderOptions.Default, and unsets Comment.Reference to prevent conflicts from duplicate default values in multi-item lists.
Validate SSA marker isolation in test coverage
pkg/types/builder_test.go
TestBuild test infrastructure gains optional commentChecks callbacks to verify comment output. A new test case SSA_InjectedKey_Not_In_Observation_Comments asserts that +listType=map and +listMapKey markers appear in Parameters.Rule comments but are absent from Observation.Rule comments, and that kubebuilder defaults do not appear on the Observation.RuleIndex field.

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 7
✅ Passed checks (7 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR successfully addresses issue #659 by implementing code changes that prevent SSA markers and injected-key defaults from being generated on Observation structs [#659].
Out of Scope Changes check ✅ Passed All changes are scoped to the linked issue: field.go strips SSA markers and clears injected-key defaults for observation fields, and builder_test.go adds test coverage for these changes.
Configuration Api Breaking Changes ✅ Passed PR contains no changes to pkg/config/** files; Configuration API is unmodified and no breaking changes were introduced.
Generated Code Manual Edits ✅ Passed PR modifies pkg/types/builder_test.go and pkg/types/field.go—neither matches zz_*.go pattern. Changes are to source code generators, not generated output files.
Template Breaking Changes ✅ Passed This PR contains no changes to pkg/controller/external*.go template files. Only pkg/types/builder_test.go and pkg/types/field.go were modified to fix SSA marker handling on Observation fields.
Description check ✅ Passed The pull request description clearly relates to the changeset, explaining the removal of SSA markers and injected key defaults from observation fields to fix issue #659.
Title check ✅ Passed The title clearly describes the main change: preventing SSA options and injected key defaults from being added to observation/status fields, which directly addresses issue #659.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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 and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
pkg/types/builder_test.go (1)

642-642: ⚡ Quick win

Please rename the test case key to PascalCase (no underscores).

Nice coverage addition here. Could you rename "SSA_InjectedKey_Not_In_Observation_Comments" to a PascalCase form (for example, SSAInjectedKeyNotInObservationComments) to match repo test naming conventions? Thanks for adding this regression case.

As per coding guidelines, **/*_test.go: “Enforce table-driven test structure: PascalCase test names (no underscores)”.

🤖 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 `@pkg/types/builder_test.go` at line 642, Rename the table-driven test case key
"SSA_InjectedKey_Not_In_Observation_Comments" to a PascalCase identifier (no
underscores), e.g., SSAInjectedKeyNotInObservationComments, so it matches the
repository's test naming convention; update any places that reference this map
key inside builder_test.go (the test cases map entry and any lookups/assertions)
to use the new PascalCase name.
🤖 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 `@pkg/types/builder_test.go`:
- Line 642: Rename the table-driven test case key
"SSA_InjectedKey_Not_In_Observation_Comments" to a PascalCase identifier (no
underscores), e.g., SSAInjectedKeyNotInObservationComments, so it matches the
repository's test naming convention; update any places that reference this map
key inside builder_test.go (the test cases map entry and any lookups/assertions)
to use the new PascalCase name.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 89a04c5c-8ca1-44c4-ab0b-02e8246b30d5

📥 Commits

Reviewing files that changed from the base of the PR and between 0beea8e and a7c0393.

📒 Files selected for processing (2)
  • pkg/types/builder_test.go
  • pkg/types/field.go

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.

SSA markers fails on Observation for multi-item lists

1 participant