iflytek/astron-agent · error · CustomException
(CustomException ErrorResponse)
Error message
${e.message} (CustomException ErrorResponse) What it means
The same handle_rag_operation wrapper also catches CustomException, the service's own business-logic exception. It logs, records the span, increments metrics with e.code, synthesizes a CodeEnum-like object, and returns ErrorResponse with the business error code and message. Unlike ThirdPartyException this signals a domain-rule violation inside the knowledge service rather than an upstream dependency failure.
Solutions
- Read e.message to identify which business rule failed
- Validate the target resource exists before calling the API (correct file/chunk/knowledge-base IDs)
- Fix the request payload to satisfy the domain constraint
- If the rule itself is wrong, adjust the service-layer validation that raises CustomException
Example fix
// before
delete_chunk(chunk_id) # may raise CustomException
// after
if not chunk_exists(chunk_id):
raise CustomException(code=CodeEnum.DataNotFoundException.code, message=f"chunk {chunk_id} not found") Defensive patterns
Strategy: validation
Validate before calling
def validate_chunk_request(file_id, chunk_ids):
if not file_exists(file_id):
raise ValueError(f"file {file_id} does not exist")
if any(not chunk_exists(c) for c in chunk_ids):
raise ValueError("one or more chunks do not exist") Type guard
def is_business_error(resp: dict) -> bool:
return isinstance(resp, dict) and resp.get("code", 0) != 0 and resp.get("code") not in SYSTEM_ERROR_CODES Try / catch
try:
resp = rag_api.chunk_update(payload)
except CustomException as e:
log.info("business rule rejected: code=%s msg=%s", e.code, e.message)
resp = None # surface e.message to the end user as validation feedback Prevention
- Resolve resource IDs (files, chunks, KBs) through the list/query APIs before mutating them
- Keep domain validation messages user-actionable
- Sync client-side validation rules with server-side CustomException rules
- Write tests asserting CustomException codes for known-invalid requests
When it happens
Trigger: RAG API calls where business rules reject the request: invalid chunk indices in chunk_update/chunk_delete, nonexistent file/knowledge-base IDs, quota or state violations raised as CustomException by the service layer.
Common situations: Client operating on a deleted document; chunk_query with an out-of-range offset; domain validators rejecting payloads that pass schema validation.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- (ThirdPartyException ErrorResponse)
- Internal server error
- SparkDesk-RAG does not support split operation.
- SparkDesk-RAG does not support chunks_save operation.
- SparkDesk-RAG does not support chunks_update operation.
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/06aabf19bf399ead.
Report an issue: GitHub.
Appendix: source
Thrown at core/knowledge/api/v1/api.py:150
except ProtocolParamException as e:
error_msg = f"{operation_callable.__name__} ProtocolParamException, reason {e}"
logger.error(error_msg)
span_context.record_exception(e)
metric.in_error_count(code=CodeEnum.ParameterCheckException.code)
return ErrorResponse(code_enum=CodeEnum.ParameterCheckException, message=str(e))
except ThirdPartyException as e:
error_msg = f"{operation_callable.__name__} err (ThirdParty), reason {e}"
logger.error(error_msg)
span_context.record_exception(e)
metric.in_error_count(code=e.code)
# Create a CodeEnum-like object for the response
error_code = type("ErrorCode", (), {"code": e.code, "msg": e.message})()
return ErrorResponse(code_enum=error_code, message=e.message)
except CustomException as e:
error_msg = f"{operation_callable.__name__} err (Custom), reason {e}"
logger.error(error_msg)
span_context.record_exception(e)
metric.in_error_count(code=e.code)
# Create a CodeEnum-like object for the response
error_code = type("ErrorCode", (), {"code": e.code, "msg": e.message})()
return ErrorResponse(code_enum=error_code, message=e.message)
except Exception as e: # pylint: disable=W0718
# Intentionally catch all exceptions here as part of global exception handling
error_msg = f"{operation_callable.__name__} err (Unexpected), reason {e}"
logger.error(error_msg)
span_context.record_exception(e)
metric.in_error_count(code=CodeEnum.ServiceException.code)
return ErrorResponse(
code_enum=CodeEnum.ServiceException,
message=f"Internal server error:{error_msg}",
)
View on GitHub (pinned to 5e758547a8)