Skip to content

Fix get_item() returning HTTP 500 for a not-found snippet#400

Merged
sheabunge merged 1 commit into
codesnippetspro:core-betafrom
thisismyurl:fix/get-item-rest-status-404
Jun 4, 2026
Merged

Fix get_item() returning HTTP 500 for a not-found snippet#400
sheabunge merged 1 commit into
codesnippetspro:core-betafrom
thisismyurl:fix/get-item-rest-status-404

Conversation

@thisismyurl
Copy link
Copy Markdown
Contributor

Hey folks,

get_item() in the REST controller returns HTTP 500 when a snippet ID doesn't exist. That should be 404 — 500 means something went wrong on the server, 404 means the resource doesn't exist. The activate_item() and deactivate_item() methods in the same file already return 404 for the same not-found condition, so get_item() was just the odd one out. One digit change.

(full disclosure, I used AI help with the testing and tweaks - Christopher)

A snippet that doesn't exist should return 404, not 500. HTTP 500
signals a server error; 404 signals that the resource doesn't exist.
The activate_item() and deactivate_item() methods in this same file
already return 404 for the same not-found condition — get_item() was
the outlier.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 1, 2026 15:12
Copy link
Copy Markdown
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

Note

Copilot was unable to run its full agentic suite in this review.

Adjusts the REST API error response for missing snippets to use an appropriate HTTP status code.

Changes:

  • Update the rest_cannot_get error status from 500 to 404 when a snippet is not found.

@sheabunge
Copy link
Copy Markdown
Member

Great catch – thank you for the contribution!

@sheabunge sheabunge merged commit d489240 into codesnippetspro:core-beta Jun 4, 2026
5 checks passed
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.

3 participants