alibaba / alibaba/ROCK

[Feature] Unified proxy response structure to standardize API responses

Open
#594 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
485
Forks
81
Avg merge
16h 12m
Merged PRs (30d)
8

Description

## Problem Statement

The current sandbox proxy responses lack a consistent structure making integration difficult. The different endpoints return different response structures which complicates client-side handling.

## Proposed Solution

Standardize all API responses to follow consistent structure as described in the new interface response body specification:
- A standardized response wrapper (BaseResponse with status, message, error fields)
- Consistent result objects containing code and failure_reason
- Proper inheritance hierarchy for all response type classes

## Changes Made

- Created specification document at `docs/_specs/response/interface_response_body_spec.md`
- Refactored response classes in `rock/actions/sandbox/response.py` to inherit from `SandboxResponse`
- Added `code` and `failure_reason` fields to all response types
- Updated API endpoint responses to use the `RockResponse[SpecificResponseType]` wrapper
- Added tests in `tests/unit/test_sandbox_response.py` to validate compliance
- Moved interface specification file to proper location for documentation organization

## Benefits

- Consistent API response format makes integration easier
- Clear documentation of response structures
- Better error handling with standardized error fields
- Improved API predictability

## Component Affected

- [x] Sandbox
- [x] Actions
- [x] SDK & API
- [x] Documentation & Examples

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with docs/_specs/response/interface_response_body_spec.md to understand the response body requirements, then read rock/actions/sandbox/response.py and tests/unit/test_sandbox_response.py. Check the sandbox API endpoint responses and verify that the response classes, fields, wrappers, and inheritance match the specification and that the tests validate compliance.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend, documentation, testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.