Skip to content

feat: add helpful hints when connection create/upsert fails with invalid resource IDs#205

Merged
leggetter merged 6 commits intomainfrom
feat/improve-error-messages
Feb 5, 2026
Merged

feat: add helpful hints when connection create/upsert fails with invalid resource IDs#205
leggetter merged 6 commits intomainfrom
feat/improve-error-messages

Conversation

@leggetter
Copy link
Collaborator

Summary

Fixes #204

When using --source-id or --destination-id flags and the API returns a 404 Not Found error, the CLI now displays helpful hints about expected ID formats to help users identify when they've provided the wrong type of ID.

Changes

  • Added enhanceConnectionError() shared method in connection_create.go that detects 404/Not Found errors
  • When --source-id or --destination-id is provided and an error occurs, displays hints about ID formats
  • Both connection create and connection upsert commands share the same logic
  • Added 6 acceptance tests covering error scenarios and positive case

Example Output

For the bug report scenario where a connection ID (web_) was mistakenly used instead of a source ID (src_):

$ hookdeck connection create --name "octolens-mentions-raw" \
    --source-id "web_y0A7nz0tRxZy" \
    --destination-type HTTP \
    --destination-name "modal-octolens-mentions-raw" \
    --destination-url "https://example.com"

failed to create connection: error: Not Found

Hints:
  - --source-id 'web_y0A7nz0tRxZy' was provided. Source IDs typically start with 'src_'.

Please verify the resource IDs exist and are the correct type.

Test Plan

  • Added acceptance tests for non-existent source ID
  • Added acceptance tests for non-existent destination ID
  • Added acceptance test reproducing issue connection create command failing #204 (wrong ID type)
  • Added acceptance tests for upsert command
  • Added positive test for valid existing source ID
  • All existing acceptance tests pass

Made with Cursor

…lid resource IDs

When using --source-id or --destination-id flags and the API returns a 404 Not Found
error, the CLI now displays helpful hints about expected ID formats:

- Source IDs typically start with 'src_'
- Destination IDs typically start with 'des_'

This helps users identify when they've provided the wrong type of ID (e.g., using
a connection ID 'web_xxx' instead of a source ID 'src_xxx').

Fixes #204

Example output for the bug report scenario:
```
$ hookdeck connection create --name "my-conn" --source-id "web_y0A7nz0tRxZy" \
    --destination-type HTTP --destination-name "my-dest" \
    --destination-url "https://example.com"

failed to create connection: error: Not Found

Hints:
  - --source-id 'web_y0A7nz0tRxZy' was provided. Source IDs typically start with 'src_'.

Please verify the resource IDs exist and are the correct type.
```

Co-authored-by: Cursor <cursoragent@cursor.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds helpful error hints when connection create/upsert commands fail with 404 Not Found errors, helping users identify when they've provided incorrect resource ID types (e.g., using a connection ID instead of a source ID).

Changes:

  • Added error enhancement logic that detects 404 errors and displays hints about expected ID format for --source-id and --destination-id flags
  • Shared enhanceConnectionError() method between connection create and connection upsert commands
  • Added 6 acceptance tests covering error scenarios with non-existent IDs, wrong ID types, and a positive test case

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
pkg/cmd/connection_create.go Added enhanceCreateError() and enhanceConnectionError() methods to detect 404 errors and provide helpful hints about resource ID formats
pkg/cmd/connection_upsert.go Updated error handling to use the shared enhanceConnectionError() method from the embedded connectionCreateCmd
test/acceptance/connection_error_hints_test.go Added comprehensive acceptance tests covering error scenarios with non-existent source/destination IDs, wrong ID types, and valid existing source ID usage

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

hints = append(hints, fmt.Sprintf(" - --source-id '%s' was provided. Source IDs typically start with 'src_'.", cc.sourceID))
}
if cc.destinationID != "" {
hints = append(hints, fmt.Sprintf(" - --destination-id '%s' was provided. Destination IDs typically start with 'des_'.", cc.destinationID))
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The destination ID prefix in the hint message is incorrect. According to the documentation (REFERENCE.md:906) and unit tests (pkg/hookdeck/connections_test.go:270), destination IDs use the prefix 'dest_', not 'des_'. The hint message should say "Destination IDs typically start with 'dest_'." to be consistent with the actual API.

Suggested change
hints = append(hints, fmt.Sprintf(" - --destination-id '%s' was provided. Destination IDs typically start with 'des_'.", cc.destinationID))
hints = append(hints, fmt.Sprintf(" - --destination-id '%s' was provided. Destination IDs typically start with 'dest_'.", cc.destinationID))

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@copilot you are incorrect. destination IDs start with des_. Where did you get your information from?
CleanShot 2026-02-05 at 11 10 49


connName := "test-bad-dst-" + timestamp
sourceName := "test-src-" + timestamp
fakeDestinationID := "des_nonexistent123"
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The fake destination ID uses an incorrect prefix. According to the documentation (REFERENCE.md:906) and unit tests (pkg/hookdeck/connections_test.go:270), destination IDs should use the prefix 'dest_', not 'des_'. Change this to "dest_nonexistent123" to match the actual API format.

Copilot uses AI. Check for mistakes.
assert.Contains(t, combinedOutput, "Hints:", "Should contain hints section")
assert.Contains(t, combinedOutput, "--destination-id", "Hint should mention --destination-id flag")
assert.Contains(t, combinedOutput, fakeDestinationID, "Hint should include the provided destination ID")
assert.Contains(t, combinedOutput, "des_", "Hint should mention destination ID prefix format")
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The test assertion checks for the incorrect prefix 'des_'. According to the documentation (REFERENCE.md:906) and unit tests (pkg/hookdeck/connections_test.go:270), destination IDs should use the prefix 'dest_', not 'des_'. Update this assertion to check for "dest_" instead.

Suggested change
assert.Contains(t, combinedOutput, "des_", "Hint should mention destination ID prefix format")
assert.Contains(t, combinedOutput, "dest_", "Hint should mention destination ID prefix format")

Copilot uses AI. Check for mistakes.

connName := "test-upsert-bad-dst-" + timestamp
sourceName := "test-src-" + timestamp
fakeDestinationID := "des_nonexistent456"
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The fake destination ID uses an incorrect prefix. According to the documentation (REFERENCE.md:906) and unit tests (pkg/hookdeck/connections_test.go:270), destination IDs should use the prefix 'dest_', not 'des_'. Change this to "dest_nonexistent456" to match the actual API format.

Copilot uses AI. Check for mistakes.
assert.Contains(t, combinedOutput, "Hints:", "Should contain hints section")
assert.Contains(t, combinedOutput, "--destination-id", "Hint should mention --destination-id flag")
assert.Contains(t, combinedOutput, fakeDestinationID, "Hint should include the provided destination ID")
assert.Contains(t, combinedOutput, "des_", "Hint should mention destination ID prefix format")
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The test assertion checks for the incorrect prefix 'des_'. According to the documentation (REFERENCE.md:906) and unit tests (pkg/hookdeck/connections_test.go:270), destination IDs should use the prefix 'dest_', not 'des_'. Update this assertion to check for "dest_" instead.

Suggested change
assert.Contains(t, combinedOutput, "des_", "Hint should mention destination ID prefix format")
assert.Contains(t, combinedOutput, "dest_", "Hint should mention destination ID prefix format")

Copilot uses AI. Check for mistakes.
require.NotEmpty(t, initialConn.ID, "Initial connection should have ID")

// Get the source ID from the created connection
sourceID := initialConn.Source.Name // We need the actual source ID, not name
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

This line is unnecessary and creates dead code. The variable sourceID is immediately reassigned on line 221 after fetching the connection details. The comment on this line even acknowledges this is incorrect ("We need the actual source ID, not name"). Remove this line and the comment, and declare sourceID as var sourceID string instead.

Suggested change
sourceID := initialConn.Source.Name // We need the actual source ID, not name
var sourceID string

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Copilot AI commented Feb 5, 2026

@leggetter I've opened a new pull request, #206, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 4 commits February 5, 2026 11:13
Co-authored-by: leggetter <328367+leggetter@users.noreply.github.com>
Co-authored-by: leggetter <328367+leggetter@users.noreply.github.com>
fix: correct destination ID prefix from dest_ to des_ across codebase
Remove unnecessary sourceID assignment that was immediately overwritten.

Co-authored-by: Cursor <cursoragent@cursor.com>
@leggetter leggetter merged commit b0cd334 into main Feb 5, 2026
7 checks passed
@leggetter leggetter deleted the feat/improve-error-messages branch February 5, 2026 18:40
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.

connection create command failing

2 participants