Skip to content

Fix connection upsert bugs with rules, auth, and partial updates#221

Merged
leggetter merged 3 commits intomainfrom
claude/fix-reported-bug-rHNax
Feb 27, 2026
Merged

Fix connection upsert bugs with rules, auth, and partial updates#221
leggetter merged 3 commits intomainfrom
claude/fix-reported-bug-rHNax

Conversation

@leggetter
Copy link
Collaborator

@leggetter leggetter commented Feb 25, 2026

Summary

This PR fixes three critical bugs in the connection upsert command that prevented proper handling of retry rules, destination authentication, and partial source/destination updates.

fixes #209

Key Changes

Bug 1: Preserve destination/source by ID when upserting rules only

  • Modified buildUpsertRequest() to reference existing source/destination by ID instead of sending full objects when only rule flags are provided
  • This prevents incomplete auth configuration from being sent to the API when updating just the rules
  • Added logic to detect when only rule/config flags are provided vs. actual source/destination changes

Bug 2: Allow partial source/destination updates without type

  • Relaxed validation in validateSourceFlags() and validateDestinationFlags() to allow --source-name or --destination-name alone on existing connections
  • Changed default destination-cli-path from "/" to "" to avoid false positives in flag detection
  • Added logic to fetch existing connection when partial inline updates are detected, so the existing type can be preserved
  • Updated comments to clarify that the API will validate incomplete data if it's actually a create operation

Bug 3: Send retry response status codes as array, not string

  • Fixed buildConnectionRules() to split comma-separated status codes and send them as a []string array instead of a single string
  • Added trimming of whitespace around individual codes to handle formats like "500, 502, 503"

Testing

  • Added comprehensive unit tests in pkg/cmd/connection_upsert_test.go covering all three bugs
  • Added acceptance tests in test/acceptance/connection_upsert_test.go for regression testing
  • Added acceptance tests in test/acceptance/connection_test.go and test/acceptance/connection_update_test.go to verify status codes are sent as arrays
  • Added GitHub Actions workflow step to run unit tests on every push/PR

Implementation Details

  • The upsert command now intelligently determines whether to fetch the existing connection based on what flags are provided
  • When partial updates are detected (e.g., name without type), the existing connection is fetched to fill in missing required fields
  • Status code parsing is consistent across create, update, and upsert commands

https://claude.ai/code/session_01D8k5gyzeqzjZUanVrwv5dL

…estination auth

Fixes three bugs reported in #209:

1. Auth type sent without credentials: The `destination-cli-path` flag
   defaulted to "/" in the upsert command, making `hasAnyDestinationFlag()`
   always return true. This caused `buildDestinationInputForUpdate` to copy
   the entire existing destination config (including auth_type) even when no
   destination flags were provided, sending auth_type without credentials.
   Fix: Change the default to "" for upsert and add a destination ID
   preservation fallback.

2. Source name validation issue: `validateSourceFlags()` required both
   --source-name and --source-type even during upsert updates. For updates,
   providing just --source-name should be valid since the existing type can
   be preserved.
   Fix: Relax validation for upsert and fill in missing type from existing
   connection.

3. Status code format problem: `buildConnectionRules` sent
   `response_status_codes` as a single comma-separated string instead of
   parsing it into a string array, causing API rejection.
   Fix: Split the comma-separated string into a []string array.

Note: Bug 3 fix affects all commands using buildConnectionRules (create,
update, upsert) since the function is shared.

https://claude.ai/code/session_01D8k5gyzeqzjZUanVrwv5dL
…ames

Move acceptance tests from separate connection_upsert_bugs_test.go into
the existing connection_upsert_test.go (as subtests of
TestConnectionUpsertPartialUpdates) and connection_update_test.go.

Rename unit tests from connection_upsert_bugs_test.go to
connection_upsert_test.go with descriptive test function names.

https://claude.ai/code/session_01D8k5gyzeqzjZUanVrwv5dL
- Add unit-test job to test.yml that runs `go test -short ./pkg/...`
  on every PR. Previously only GoReleaser builds ran, so unit test
  failures were never caught.

- Fix TestSourceCreateRequiresName: the old test executed the real root
  command which hit ValidateAPIKey() before cobra's required-flag check,
  causing a misleading "not authenticated" error. Replaced with a direct
  check that --name and --type have the required-flag annotation.

- Add TestConnectionCreateRetryResponseStatusCodes acceptance test for
  Bug 3 coverage on the create command path (update and upsert were
  already covered).

https://claude.ai/code/session_01D8k5gyzeqzjZUanVrwv5dL
@leggetter leggetter merged commit 0066e7b into main Feb 27, 2026
8 of 10 checks passed
@leggetter leggetter deleted the claude/fix-reported-bug-rHNax branch February 27, 2026 10:37
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.

fix: connection upsert fails when updating rules on connection with destination auth

2 participants