Skip to content

Improve user ID validation error messages and request body checks - #22

Merged
ShadowInCache merged 1 commit into
stealthwhizz:mainfrom
ShadowInCache:main
Apr 5, 2026
Merged

ShadowInCache merged 1 commit into
stealthwhizz:mainfrom
ShadowInCache:main

Conversation

@ShadowInCache

@ShadowInCache ShadowInCache commented Apr 5, 2026 •

Copy link
Copy Markdown
Collaborator

… body checks

Summary by CodeRabbit

  • Bug Fixes

    • Improved error handling for invalid user references in event creation.
    • Enhanced validation for bulk user operations to properly reject malformed requests.
  • Tests

    • Added test coverage for event creation validation and bulk operation error handling.
  • Chores

    • Updated monitoring metrics.

@coderabbitai

coderabbitai Bot commented Apr 5, 2026 •

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f32aa5a3-5d42-4e19-9da7-8beaf8d072af

📥 Commits

Reviewing files that changed from the base of the PR and between 0d61691 and 6646b12.

📒 Files selected for processing (4)
  • app/routes/events.py
  • app/routes/users.py
  • app/tests/test_integration.py
  • security/canary_state.env

📝 Walkthrough

Walkthrough

This pull request improves error handling and request validation across two API endpoints. The /events endpoint error message for non-existent users was updated. The /users/bulk endpoint now properly differentiates between missing request bodies and invalid JSON payloads. Three corresponding integration tests were added, and runtime canary metrics were updated.

Changes

Cohort / File(s) Summary
Error Message Update
app/routes/events.py
Updated 404 error message for non-existent user_id from "invalid user_id" to "User not found".
Request Validation Enhancement
app/routes/users.py
Modified POST /users/bulk parsing to differentiate between missing/empty body (sets data = {}), non-empty body with invalid JSON (returns 400), and non-dictionary JSON (returns 400 instead of defaulting to {}).
Test Coverage Addition
app/tests/test_integration.py
Added three new tests: one verifying consecutive URL creations use distinct short codes, one validating the updated event 404 error response, and one confirming bulk user creation rejects non-object JSON with appropriate 400 response.
Canary Metrics Update
security/canary_state.env
Updated runtime canary state metrics: success total count increased from 1286 to 1406, last run timestamp updated, and latency measurements for multiple demo services adjusted.

Possibly Related PRs

Poem

🐰 With better messages and clearer validation,
The API's refined with each correction,
User not found now speaks with clarity,
Request bodies parsed with great rarity,
Tests ensure the logic's right! ✨


🎯 2 (Simple) | ⏱️ ~12 minutes

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@ShadowInCache
ShadowInCache merged commit 096f864 into stealthwhizz:main Apr 5, 2026
2 of 3 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.

1 participant