Skip to content

fix(auto-monitor-setups): update bulk upsert to atomic semantics#173

Open
galzilber wants to merge 1 commit into
mainfrom
gz/update-batch-docs
Open

fix(auto-monitor-setups): update bulk upsert to atomic semantics#173
galzilber wants to merge 1 commit into
mainfrom
gz/update-batch-docs

Conversation

@galzilber

@galzilber galzilber commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Updates the bulk upsert endpoint docs (POST /v2/auto-monitor-setups/bulk) to match the current api-service implementation, which changed from per-item partial success to atomic all-or-nothing. Success is now 200 OK with a flat array of full setup objects (previously 207 Multi-Status with per-item {status, result, error} wrappers). 400 now also covers per-item validation errors with the exact error strings from the handler, and the 500 body was corrected to {"error": "Internal server error"}.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Updated the bulk auto-monitor setup API docs to reflect all-or-nothing behavior for batch requests.
    • Clarified that successful requests return 200 OK with full setup details in request order.
    • Revised error responses to show that validation failures reject the entire batch, and server errors do not save partial results.
    • Removed the old per-item partial success response format from the examples.

The bulk upsert endpoint changed from per-item partial success
(207 Multi-Status) to atomic all-or-nothing. Update the docs to match:
200 OK with a flat list of full setups on success, 400 for request- and
per-item validation errors, 500 for DB failures.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@galzilber galzilber changed the title docs(auto-monitor-setups): update bulk upsert to atomic semantics fix(auto-monitor-setups): update bulk upsert to atomic semantics Jul 9, 2026
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Documentation for POST /v2/auto-monitor-setups/bulk was updated to describe atomic all-or-nothing batch semantics instead of partial success. The 207 Multi-Status per-item model was removed; 200 OK, 400 Bad Request, and 500 Internal Server Error response examples were revised accordingly.

Changes

Documentation update for atomic bulk semantics

Layer / File(s) Summary
Atomic semantics and response documentation update
api-reference/auto-monitor-setups/bulk-upsert-auto-monitor-setups.mdx
Replaces "Partial Success Semantics" with "Atomic Semantics", removes the 207 Multi-Status per-item ok/error model, updates 200 OK to return full setup objects in request order, revises 400 Bad Request causes and first-offending-item error format, and adjusts the 500 error example casing and payload.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

  • traceloop/docs#170: Prior PR on the same documentation page changing the response contract from 207 Multi-Status partial success to atomic semantics, with corresponding 400/500 examples.

Suggested reviewers: max-deygin-traceloop

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: bulk upsert docs were updated to reflect atomic semantics.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch gz/update-batch-docs

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@api-reference/auto-monitor-setups/bulk-upsert-auto-monitor-setups.mdx`:
- Around line 64-107: The 200 OK example and description in
bulk-upsert-auto-monitor-setups.mdx are inconsistent with the stated flat-array
response shape. Update the documented success payload to match the actual
contract used by the bulk upsert endpoint, and make sure the narrative near the
example aligns with that shape by referencing the bulk-upsert auto monitor
setups response and its `200 OK` section.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1c87cc6c-4d96-45df-b531-5a66da712719

📥 Commits

Reviewing files that changed from the base of the PR and between 196cabc and 1a147ab.

📒 Files selected for processing (1)
  • api-reference/auto-monitor-setups/bulk-upsert-auto-monitor-setups.mdx

Comment on lines +64 to 107
### 200 OK

Returned when the batch is accepted. The `setups` array contains one entry per input item, in the **same order** as the request.

Each entry has:

| Field | Type | Description |
|-------|------|-------------|
| `external_id` | string | The `external_id` of the input item. |
| `status` | string | `ok` if the item was upserted, `error` if it failed. |
| `result` | object | Present when `status` is `ok`. The full upserted setup, matching the [Create](/api-reference/auto-monitor-setups/create-an-auto-monitor-setup) response shape. |
| `error` | string | Present when `status` is `error`. Human-readable message prefixed with the item index, e.g. `setups[1]: unknown evaluator slug "..."`. Internal errors are reported as `setups[N]: internal error` — the underlying cause is logged server-side but not returned to the client. |
Returned when the entire batch is upserted successfully. The `setups` array contains one entry per input item, in the **same order** as the request. Each entry is a full setup object, matching the [Create](/api-reference/auto-monitor-setups/create-an-auto-monitor-setup) response shape.

```json
{
"setups": [
{
"id": "cmm...",
"external_id": "openai-gpt4o-monitor",
"status": "ok",
"result": {
"id": "cmm...",
"external_id": "openai-gpt4o-monitor",
"org_id": "c108269c-...",
"project_id": "cm9v2g95l...",
"env_project_id": "cm9v2ga9i...",
"init_rules": [
{ "key": "gen_ai.system", "value": "openai", "source": "span_attributes", "operator": "equals" },
{ "key": "gen_ai.request.model", "value": "gpt-4o", "source": "span_attributes", "operator": "equals" }
],
"evaluators": [
{ "evaluator_type": "answer-relevancy", "status": "pending" },
{ "evaluator_type": "toxicity-detector", "status": "pending" }
],
"status": "pending",
"created_at": "2026-05-20T10:30:00Z",
"updated_at": "2026-05-20T10:30:00Z"
}
"org_id": "c108269c-...",
"project_id": "cm9v2g95l...",
"env_project_id": "cm9v2ga9i...",
"init_rules": [
{ "key": "gen_ai.system", "value": "openai", "source": "span_attributes", "operator": "equals" },
{ "key": "gen_ai.request.model", "value": "gpt-4o", "source": "span_attributes", "operator": "equals" }
],
"evaluators": [
{ "evaluator_type": "answer-relevancy", "status": "pending" },
{ "evaluator_type": "toxicity-detector", "status": "pending" }
],
"status": "pending",
"created_at": "2026-05-20T10:30:00Z",
"updated_at": "2026-05-20T10:30:00Z"
},
{
"id": "cmm...",
"external_id": "anthropic-monitor",
"status": "error",
"error": "setups[1]: unknown evaluator slug \"answer-relevancy-typo\""
"org_id": "c108269c-...",
"project_id": "cm9v2g95l...",
"env_project_id": "cm9v2ga9i...",
"init_rules": [
{ "key": "gen_ai.system", "value": "anthropic", "source": "span_attributes", "operator": "equals" }
],
"evaluators": [
{ "evaluator_type": "answer-relevancy", "status": "pending" }
],
"status": "pending",
"created_at": "2026-05-20T10:30:00Z",
"updated_at": "2026-05-20T10:30:00Z"
}
]
}
```

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.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Response shape contradicts stated behavior — flat array vs. object wrapper.

The PR objectives state the success response is "a flat array of full setup objects," but the documented 200 OK example wraps the array in a setups key ({"setups": [...]}). One of these is wrong; if the actual API returns a bare array, this example and the accompanying description ("The setups array contains one entry per input item...") need correcting to match the real contract.

📝 Proposed fix if the API returns a bare array
 ### 200 OK
 
-Returned when the entire batch is upserted successfully. The `setups` array contains one entry per input item, in the **same order** as the request. Each entry is a full setup object, matching the [Create](/api-reference/auto-monitor-setups/create-an-auto-monitor-setup) response shape.
+Returned when the entire batch is upserted successfully. The response is a flat array with one entry per input item, in the **same order** as the request. Each entry is a full setup object, matching the [Create](/api-reference/auto-monitor-setups/create-an-auto-monitor-setup) response shape.
 
 ```json
-{
-  "setups": [
-    {
+[
+  {
       ...
-    }
-  ]
-}
+  }
+]
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
### 200 OK
Returned when the batch is accepted. The `setups` array contains one entry per input item, in the **same order** as the request.
Each entry has:
| Field | Type | Description |
|-------|------|-------------|
| `external_id` | string | The `external_id` of the input item. |
| `status` | string | `ok` if the item was upserted, `error` if it failed. |
| `result` | object | Present when `status` is `ok`. The full upserted setup, matching the [Create](/api-reference/auto-monitor-setups/create-an-auto-monitor-setup) response shape. |
| `error` | string | Present when `status` is `error`. Human-readable message prefixed with the item index, e.g. `setups[1]: unknown evaluator slug "..."`. Internal errors are reported as `setups[N]: internal error` — the underlying cause is logged server-side but not returned to the client. |
Returned when the entire batch is upserted successfully. The `setups` array contains one entry per input item, in the **same order** as the request. Each entry is a full setup object, matching the [Create](/api-reference/auto-monitor-setups/create-an-auto-monitor-setup) response shape.
```json
{
"setups": [
{
"id": "cmm...",
"external_id": "openai-gpt4o-monitor",
"status": "ok",
"result": {
"id": "cmm...",
"external_id": "openai-gpt4o-monitor",
"org_id": "c108269c-...",
"project_id": "cm9v2g95l...",
"env_project_id": "cm9v2ga9i...",
"init_rules": [
{ "key": "gen_ai.system", "value": "openai", "source": "span_attributes", "operator": "equals" },
{ "key": "gen_ai.request.model", "value": "gpt-4o", "source": "span_attributes", "operator": "equals" }
],
"evaluators": [
{ "evaluator_type": "answer-relevancy", "status": "pending" },
{ "evaluator_type": "toxicity-detector", "status": "pending" }
],
"status": "pending",
"created_at": "2026-05-20T10:30:00Z",
"updated_at": "2026-05-20T10:30:00Z"
}
"org_id": "c108269c-...",
"project_id": "cm9v2g95l...",
"env_project_id": "cm9v2ga9i...",
"init_rules": [
{ "key": "gen_ai.system", "value": "openai", "source": "span_attributes", "operator": "equals" },
{ "key": "gen_ai.request.model", "value": "gpt-4o", "source": "span_attributes", "operator": "equals" }
],
"evaluators": [
{ "evaluator_type": "answer-relevancy", "status": "pending" },
{ "evaluator_type": "toxicity-detector", "status": "pending" }
],
"status": "pending",
"created_at": "2026-05-20T10:30:00Z",
"updated_at": "2026-05-20T10:30:00Z"
},
{
"id": "cmm...",
"external_id": "anthropic-monitor",
"status": "error",
"error": "setups[1]: unknown evaluator slug \"answer-relevancy-typo\""
"org_id": "c108269c-...",
"project_id": "cm9v2g95l...",
"env_project_id": "cm9v2ga9i...",
"init_rules": [
{ "key": "gen_ai.system", "value": "anthropic", "source": "span_attributes", "operator": "equals" }
],
"evaluators": [
{ "evaluator_type": "answer-relevancy", "status": "pending" }
],
"status": "pending",
"created_at": "2026-05-20T10:30:00Z",
"updated_at": "2026-05-20T10:30:00Z"
}
]
}
```
### 200 OK
Returned when the entire batch is upserted successfully. The response is a flat array with one entry per input item, in the **same order** as the request. Each entry is a full setup object, matching the [Create](/api-reference/auto-monitor-setups/create-an-auto-monitor-setup) response shape.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@api-reference/auto-monitor-setups/bulk-upsert-auto-monitor-setups.mdx` around
lines 64 - 107, The 200 OK example and description in
bulk-upsert-auto-monitor-setups.mdx are inconsistent with the stated flat-array
response shape. Update the documented success payload to match the actual
contract used by the bulk upsert endpoint, and make sure the narrative near the
example aligns with that shape by referencing the bulk-upsert auto monitor
setups response and its `200 OK` section.

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.

2 participants