Skip to content

ref(issues): Move project codeowners endpoints and tests to issues folder #97434

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

JoshFerge
Copy link
Member

Copy link

linear bot commented Aug 7, 2025

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Aug 7, 2025
"schema": validated_data,
}
except ValidationError as e:
raise serializers.ValidationError(str(e))

Check warning

Code scanning / CodeQL

Information exposure through an exception Medium

Stack trace information
flows to this location and may be exposed to an external user.

Copilot Autofix

AI 4 days ago

To fix the problem, we should avoid exposing the string representation of the caught ValidationError to the user. Instead, we should return a generic error message that does not reveal internal details. At the same time, we should log the exception (including the stack trace) for debugging purposes, so that developers can still investigate the root cause. This can be done by using sentry_sdk.capture_exception(e) (already imported and used elsewhere in the file) to log the exception, and then raising a serializers.ValidationError with a generic message such as "Invalid codeowners syntax" or "An internal error occurred while validating codeowners".

What to change:

  • In the except ValidationError as e: block (lines 89-91), call sentry_sdk.capture_exception(e) to log the exception.
  • Raise a serializers.ValidationError with a generic message instead of str(e).

No new imports or method definitions are needed, as sentry_sdk is already imported.


Suggested changeset 1
src/sentry/issues/serializers/codeowners.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/sentry/issues/serializers/codeowners.py b/src/sentry/issues/serializers/codeowners.py
--- a/src/sentry/issues/serializers/codeowners.py
+++ b/src/sentry/issues/serializers/codeowners.py
@@ -89,3 +89,4 @@
         except ValidationError as e:
-            raise serializers.ValidationError(str(e))
+            sentry_sdk.capture_exception(e)
+            raise serializers.ValidationError("Invalid CODEOWNERS syntax or associations.")
 
EOF
@@ -89,3 +89,4 @@
except ValidationError as e:
raise serializers.ValidationError(str(e))
sentry_sdk.capture_exception(e)
raise serializers.ValidationError("Invalid CODEOWNERS syntax or associations.")

Copilot is powered by AI and may make mistakes. Always verify output.
Copy link

codecov bot commented Aug 7, 2025

❌ 2 Tests Failed:

Tests completed Failed Passed Skipped
27104 2 27102 596
View the top 2 failed test(s) by shortest run time
tests.sentry.issues.endpoints.test_project_codeowners_details.ProjectCodeOwnersDetailsEndpointTestCase::test_codeowners_max_raw_length
Stack Traces | 2.97s run time
#x1B[1m#x1B[.../issues/endpoints/test_project_codeowners_details.py#x1B[0m:157: in test_codeowners_max_raw_length
    assert response.status_code == 400
#x1B[1m#x1B[31mE   assert 200 == 400#x1B[0m
#x1B[1m#x1B[31mE    +  where 200 = <Response status_code=200, "application/json">.status_code#x1B[0m
tests.sentry.api.endpoints.test_project_codeowners_details.ProjectCodeOwnersDetailsEndpointTestCase::test_codeowners_max_raw_length
Stack Traces | 3.37s run time
#x1B[1m#x1B[.../api/endpoints/test_project_codeowners_details.py#x1B[0m:157: in test_codeowners_max_raw_length
    assert response.status_code == 400
#x1B[1m#x1B[31mE   assert 200 == 400#x1B[0m
#x1B[1m#x1B[31mE    +  where 200 = <Response status_code=200, "application/json">.status_code#x1B[0m

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant