Repository navigation
fix(cases): return 400 for over-length auto-created tag names - #3779
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
The internal add-tag route let pydantic ValidationError from TagCreate (name max_length=50) escape as a 500 when create_if_missing was set and the tag identifier was 51-100 characters. Map it to 400, matching the create-case route.
Contributor
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
✅ No security or compliance issues detected. Reviewed everything up to d1868f4. Security OverviewDetected Code Changes
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist
uv run pytest tests/unit/api/test_api_internal_cases.py tests/unit/test_case_tags_service.py)ruff check,ruff format --check,basedpyrighton changed files)Description
POST /internal/cases/{case_id}/tagsaccepts atag_idof up to 100 characters (InternalCaseTagCreate). Withcreate_if_missing=true,CaseTagsService.add_case_tagpasses that value toTagCreate(name=...), which allows at most 50 characters. The pydanticValidationErrorwas not caught in the internaladd_tagroute, so it went togeneric_exception_handler. The route returned a 500 and fired an Urgent Sentry page in prod.This PR maps
ValidationErrorto a 400 in that route. That matchesPOST /internal/cases/simple, which already returns 400 for the sameTagCreateerror through itsexcept ValueError. The public tags route does not passcreate_if_missing, so it is not affected.Related Issues
Prod Sentry issue TRACECAT-RUNTIME-15F (
ValidationError: Tracecat API failureon/internal/cases/{case_id}/tags).Screenshots / Recordings
N/A (backend only)
Steps to QA
tests/unit/api/test_api_internal_cases.py::test_internal_add_case_tag_invalid_tag_name_returns_400returns 500 without this change and 400 with it.Link to Devin session: https://app.devin.ai/sessions/032bee86a4124458845be23f52f680dc
Open in Devin Desktop: https://app.devin.ai/desktop/session/032bee86a4124458845be23f52f680dc?variant=devin
Summary by cubic
Fixes the internal case add-tag route returning a 500 when an auto-created tag name exceeds 50 characters.
POST /internal/cases/{case_id}/tagswithcreate_if_missing=truenow returns a 400 when the tag name failsTagCreatevalidation, matching the behavior of the create-case route. Previously the uncaughtValidationErrortriggered an urgent Sentry page. The public tags route is unaffected since it doesn't auto-create tags.Written for commit d1868f4. Summary will update on new commits.