Skip to content

fix(planner): fix api_publication perpetual updates and delete composite ID bug#750

Closed
Copilot wants to merge 3 commits intomainfrom
copilot/bug-fix-api-publication-updates
Closed

fix(planner): fix api_publication perpetual updates and delete composite ID bug#750
Copilot wants to merge 3 commits intomainfrom
copilot/bug-fix-api-publication-updates

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 3, 2026

api_publication resources were planned for UPDATE on every apply run after initial creation, and DELETE operations used an incorrect composite ID as the portal ID.

Bugs Fixed

Perpetual false-positive UPDATEs (shouldUpdateAPIPublication)

auto_approve_registrations was always compared against a hardcoded false default when not specified in the desired config. If the server returns a non-false value (e.g., when the portal's auto_approve_applications is true), every plan run generates a spurious update.

// Before: always compared, defaults desired to false
desiredAutoApprove := false
if desired.AutoApproveRegistrations != nil {
    desiredAutoApprove = *desired.AutoApproveRegistrations
}
if current.AutoApproveRegistrations != desiredAutoApprove { // perpetual diff

// After: skip comparison entirely when not specified, consistent with visibility/auth_strategy_ids
if desired.AutoApproveRegistrations != nil {
    desiredAutoApprove := *desired.AutoApproveRegistrations
    if current.AutoApproveRegistrations != desiredAutoApprove {

Invalid DELETE calls (planAPIPublicationDelete)

ResourceID was set to "apiID:portalID" composite string. APIPublicationAdapter.Delete passes ResourceID directly as the portalID argument to DeleteAPIPublication, resulting in an API call with an invalid portal ID. Fixed to use only portalID; the API ID is already available via change.Parent.ID.

Test Coverage

  • Unit tests for shouldUpdateAPIPublication: nil auto_approve_registrations is ignored, explicit value triggers update, full idempotency when state matches
  • New 002-idempotency-check step in portal/visibility e2e scenario: runs plan after initial apply and asserts total_changes: 0

Resolves #37

Related #338

Copilot AI and others added 2 commits April 3, 2026 20:28
… bugs

- Fix shouldUpdateAPIPublication to skip auto_approve_registrations
  comparison when not explicitly specified in desired state (nil means
  "not managed"), consistent with how visibility and auth_strategy_ids
  are handled. This prevents perpetual false-positive UPDATE plans when
  the server returns a non-false auto_approve_registrations value.

- Fix planAPIPublicationDelete to use just portalID as ResourceID
  instead of composite "apiID:portalID". The adapter's Delete method
  passes ResourceID directly as the portalID to DeleteAPIPublication,
  so passing the composite string caused invalid API calls.

- Add idempotency step to portal/visibility e2e scenario to verify
  that running plan after initial apply shows 0 changes for publications.

- Add unit tests for shouldUpdateAPIPublication covering:
  - Skips auto_approve_registrations when nil (idempotency)
  - Triggers update when auto_approve_registrations is explicitly set
  - Full idempotency when all fields match current state

Agent-Logs-Url: https://github.com/Kong/kongctl/sessions/9e79fb8c-dabf-4c5d-8d8f-d3f714722f60

Co-authored-by: rspurgeon <10521262+rspurgeon@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix api_publication resources not updating properly after create fix(planner): fix api_publication perpetual updates and delete composite ID bug Apr 3, 2026
Copilot AI requested a review from rspurgeon April 3, 2026 20:32
@rspurgeon
Copy link
Copy Markdown
Collaborator

Closed as not applicable to the originating issue

@rspurgeon rspurgeon closed this Apr 7, 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.

Bug: api_publication resources are not updating properly after initial create Bug: api publication no-op changes continually detected

2 participants