UN-2190 [MISC] Auto-capture execution ID in the API deployment Postman collection - #2031
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (1)
Summary by CodeRabbit
WalkthroughAdds Postman event and collection-variable DTOs, exposes ChangesPostman execution ID flow
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Postman
participant ExecuteAPI
participant CollectionVariable
participant StatusAPI
Postman->>ExecuteAPI: Send execute request
ExecuteAPI-->>Postman: Return execution_id
Postman->>CollectionVariable: Store execution_id
Postman->>StatusAPI: Request status with {{execution_id}}
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
|
| Filename | Overview |
|---|---|
| backend/api_v2/postman_collection/dto.py | Adds ScriptItem/EventItem/VariableItem dataclasses, wires a try/catch-guarded post-response script onto the execute item, switches status URL to use {{execution_id}} variable (safe-encoded braces), and exposes a collection-level variable block. Pipeline collections inherit the base no-op, keeping their payload functionally unchanged. |
| backend/api_v2/serializers.py | Adds execution_id = CharField() to APIExecutionResponseSerializer; ExecutionResponse always populates this field (required str, no default), so no null-handling concern. |
| backend/api_v2/postman_collection/constants.py | Adds EXEC_ID_VARIABLE_NAME and STATUS_EXEC_ID_VARIABLE constants; the latter is derived from the former to prevent drift. |
| backend/api_v2/postman_collection/tests/test_dto.py | New regression test suite covering event retention/stripping, URL encoding, variable presence, script content, constant coupling, and pipeline vs. deployment shape invariants. |
| backend/api_v2/postman_collection/tests/init.py | Empty init file to make the tests directory a Python package. |
Sequence Diagram
%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant U as User (Postman)
participant E as Execute endpoint
participant S as Status endpoint
U->>E: "POST /api/{org}/{api}/ (Process document)"
E-->>U: "{"message": {"execution_id": "uuid", "execution_status": "PENDING", "status_api": "..."}}"
Note over U: Post-response script (test hook):<br/>pm.collectionVariables.set("execution_id", response.message.execution_id)
U->>S: "GET /api/{org}/{api}/?execution_id={{execution_id}}&..."
Note over U: {{execution_id}} resolved from collection variable
S-->>U: "{"status": "COMPLETED", "message": []}"
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant U as User (Postman)
participant E as Execute endpoint
participant S as Status endpoint
U->>E: "POST /api/{org}/{api}/ (Process document)"
E-->>U: "{"message": {"execution_id": "uuid", "execution_status": "PENDING", "status_api": "..."}}"
Note over U: Post-response script (test hook):<br/>pm.collectionVariables.set("execution_id", response.message.execution_id)
U->>S: "GET /api/{org}/{api}/?execution_id={{execution_id}}&..."
Note over U: {{execution_id}} resolved from collection variable
S-->>U: "{"status": "COMPLETED", "message": []}"
Reviews (4): Last reviewed commit: "Address review comments on Postman colle..." | Re-trigger Greptile
|
jaseemjaskp
left a comment
There was a problem hiding this comment.
Automated PR review (PR Review Toolkit: code-reviewer, silent-failure-hunter, type-design-analyzer, pr-test-analyzer, comment-analyzer, code-simplifier).
The change is correct and well-scoped — the capture script's response.message.execution_id path is validated by the new serializer field and the {"message": ...} response envelope, and urlencode(safe="{}") correctly preserves {{execution_id}}. The already-fixed items (serializer dropping execution_id, pipeline collection variables, non-JSON try/catch) are not re-raised.
The findings below are all new. The only substantive one is the stale-variable risk (P1); the rest are P2/P3 hardening, type-design, comment, and test-coverage suggestions.
Add a post-response script to the 'Process document' request that stores message.execution_id into a collection variable, and point the 'Execution status' request's execution_id query param at that variable. Users no longer copy-paste execution IDs between requests (mirrors the LLMWhisperer collection's whisper_hash pattern). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…PI deployments - Wrap pm.response.json() in try/catch so error pages (non-JSON) don't surface a Postman test error - Move collection variables behind APIBase.get_collection_variables() so Pipeline collections (no status request) stay variable-free Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The ExecutionResponse DTO carries execution_id but APIExecutionResponseSerializer dropped it, so the Postman capture script (and any API consumer) had to parse it out of status_api. Add it as a first-class response field; the collection script's message.execution_id lookup now matches the real payload. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- Capture script: add else branch that resets execution_id to the
default sentinel and warns, so a stale id from a previous run is
never silently reused when the execute response lacks the field.
- PostmanItem.event: use field(default_factory=list) instead of the
None/[] tri-state; to_dict() now strips empty (falsy) event blocks,
preserving existing external behavior (pipeline items omit "event").
- Constrain closed enums: EventItem.listen -> Literal["prerequest",
"test"], ScriptItem.type -> Literal["text/javascript"].
- Document the capture script's response-shape coupling and that it is
Postman's "test" hook.
- Drop unnecessary string forward-reference on get_collection_variables.
- constants: derive STATUS_EXEC_ID_VARIABLE from EXEC_ID_VARIABLE_NAME
so the two can't drift.
- Add tests for the postman_collection package covering event
strip/keep, pipeline vs api-deployment shape, shared-constant coupling
across variable/URL/JS, and the unencoded {{execution_id}} status URL.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
4bafbf7 to
f6d7d16
Compare
|
Unstract test resultsPer-group results
Critical paths
|



What
execution_idfrom its response into a collection variable via a post-response script, and the Execution status request reads{{execution_id}}from that variable. No more manual copy-pasting of execution IDs.Why
UN-2190 — minor UX gap: after executing a document asynchronously, users had to copy the execution ID from the response and paste it into the status request's
REPLACE_WITH_EXECUTION_IDplaceholder. The LLMWhisperer Postman collection already does this withwhisper_hash; this applies the same pattern.How
postman_collection/dto.py: newScriptItem/EventItem/VariableItemdataclasses;PostmanItemgets an optionalevent; the execute request carries a post-response script (pm.collectionVariables.set("execution_id", ...), guarded so non-JSON/error responses are ignored); the status URL uses{{execution_id}}(urlencode withsafe="{}"so Postman's braces survive); collection-levelvariableblock added with aREPLACE_WITH_EXECUTION_IDdefault so manual use still works.to_dict()stripsevent: nullfrom items that have no scripts.Can this PR break any existing features. If yes, please list possible items. If no, please explain why. (PS: Admins do not merge the PR without this section filled)
REPLACE_WITH_EXECUTION_IDdefault — identical to today's placeholder. The script is defensive (checksresponse.message.execution_idexists before setting).Database Migrations
Env Config
Relevant Docs
Related Issues or PRs
Notes on Testing
execution_id={{execution_id}}unescaped, and the collection-level variable is present.Screenshots
N/A
Checklist
I have read and understood the Contribution Guidelines.
🤖 Generated with Claude Code