Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/sentry/seer/explorer/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ def start_run(
on_page_context: str | None = None,
artifact_key: str | None = None,
artifact_schema: type[BaseModel] | None = None,
metadata: dict[str, Any] | None = None,
) -> int:
"""
Start a new Seer Explorer session.
Expand All @@ -202,6 +203,7 @@ def start_run(
on_page_context: Optional context from the user's screen
artifact_key: Optional key to identify this artifact (required if artifact_schema is provided)
artifact_schema: Optional Pydantic model to generate a structured artifact
metadata: Optional metadata to store with the run (e.g., stopping_point, group_id)

Returns:
int: The run ID that can be used to fetch results or continue the conversation
Expand Down Expand Up @@ -246,6 +248,9 @@ def start_run(
payload["category_key"] = self.category_key
payload["category_value"] = self.category_value

if metadata:
payload["metadata"] = metadata

body = orjson.dumps(payload, option=orjson.OPT_NON_STR_KEYS)
Comment on lines +252 to 254
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bug: The new metadata field might not be accepted by the external Seer backend, leading to runtime errors.
Severity: HIGH | Confidence: Low

🔍 Detailed Analysis

The client-side code sends a metadata field to an external Seer service, but there's no verification or integration tests to confirm the backend accepts this new parameter. If the backend has not been updated or rejects unknown fields, it could return a 400 Bad Request, causing the client to raise requests.HTTPError() and the feature to fail at runtime.

💡 Suggested Fix

Add integration tests that call the external Seer backend with the metadata parameter to verify its acceptance and proper handling. Coordinate with the Seer backend team to ensure metadata is supported.

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: src/sentry/seer/explorer/client.py#L252-L254

Potential issue: The client-side code sends a `metadata` field to an external Seer
service, but there's no verification or integration tests to confirm the backend accepts
this new parameter. If the backend has not been updated or rejects unknown fields, it
could return a `400 Bad Request`, causing the client to raise `requests.HTTPError()` and
the feature to fail at runtime.

Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 6582980

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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


response = requests.post(
Expand Down
1 change: 1 addition & 0 deletions src/sentry/seer/explorer/client_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ class SeerRunState(BaseModel):
updated_at: str
pending_user_input: PendingUserInput | None = None
repo_pr_states: dict[str, RepoPRState] = {}
metadata: dict[str, Any] | None = None

class Config:
extra = "allow"
Expand Down
Loading