feat(agent): add OpenClaw workflow trigger intake - #1458
Conversation
94b36d6 to
91aac46
Compare
There was a problem hiding this comment.
Code Review
This pull request introduces a new controlled trigger intake API for OpenClaw-to-Astron workflow triggers, including FastAPI routing, Pydantic schemas for input validation and auditing, signature verification logic (HMAC-SHA256), and unit tests. The feedback suggests catching UnicodeDecodeError in the API endpoint to prevent unhandled 500 errors when parsing invalid UTF-8 request bodies.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| except (json.JSONDecodeError, ValidationError) as exc: | ||
| return JSONResponse(status_code=422, content={"code": 422, "message": str(exc)}) |
There was a problem hiding this comment.
If the request body contains invalid UTF-8 bytes, json.loads() will raise a UnicodeDecodeError. Since UnicodeDecodeError inherits from ValueError (and not json.JSONDecodeError), it will not be caught by this except block, resulting in an unhandled 500 Internal Server Error instead of a 422 Unprocessable Entity. Catching UnicodeDecodeError explicitly ensures robust error handling for malformed request payloads.
| except (json.JSONDecodeError, ValidationError) as exc: | |
| return JSONResponse(status_code=422, content={"code": 422, "message": str(exc)}) | |
| except (json.JSONDecodeError, ValidationError, UnicodeDecodeError) as exc: | |
| return JSONResponse(status_code=422, content={"code": 422, "message": str(exc)}) |
There was a problem hiding this comment.
Addressed in latest head 03bf0ff: the endpoint now catches UnicodeDecodeError and tests/test_openclaw_trigger.py includes test_malformed_utf8_body_returns_422.
03bf0ff to
8e111b7
Compare
Signed-off-by: biqibao112212-bot <277263126+biqibao112212-bot@users.noreply.github.com>
8e111b7 to
77bb63a
Compare
| auth_mode = verify_openclaw_signature(raw_body, x_openclaw_signature) | ||
| inputs = OpenClawTriggerInputs.model_validate(json.loads(raw_body or b"{}")) | ||
| except OpenClawSignatureError as exc: | ||
| return JSONResponse(status_code=401, content={"code": 401, "message": str(exc)}) |
| except OpenClawSignatureError as exc: | ||
| return JSONResponse(status_code=401, content={"code": 401, "message": str(exc)}) | ||
| except (json.JSONDecodeError, UnicodeDecodeError, ValidationError) as exc: | ||
| return JSONResponse(status_code=422, content={"code": 422, "message": str(exc)}) |
|
This project allows you to export workflows as skills, which can then be directly imported into local agents or Claw for workflow invocation. |
Summary
/agent/v1/openclaw/triggers/workflowsintake endpoint for OpenClaw-triggered Astron workflowsCloses #1067
Validation
PYTHONPATH=D:\??\work\astron-agent\core\agent .\.venv\Scripts\python.exe -m pytest tests\test_openclaw_trigger.py -q.\.venv\Scripts\python.exe -m py_compile api\schemas\openclaw_trigger.py service\openclaw_trigger.py api\v1\openclaw_trigger.py tests\test_openclaw_trigger.py.\.venv\Scripts\python.exe -m black --check api\schemas\openclaw_trigger.py service\openclaw_trigger.py api\v1\openclaw_trigger.py tests\test_openclaw_trigger.py.\.venv\Scripts\python.exe -m isort --check-only --profile black api\schemas\openclaw_trigger.py service\openclaw_trigger.py api\v1\openclaw_trigger.py tests\test_openclaw_trigger.pygit diff --check