Skip to content

feat(agent): add OpenClaw workflow trigger intake - #1458

Open
potato112212 wants to merge 1 commit into
iflytek:mainfrom
potato112212:codex/openclaw-secure-trigger
Open

feat(agent): add OpenClaw workflow trigger intake#1458
potato112212 wants to merge 1 commit into
iflytek:mainfrom
potato112212:codex/openclaw-secure-trigger

Conversation

@potato112212

Copy link
Copy Markdown

Summary

  • add an /agent/v1/openclaw/triggers/workflows intake endpoint for OpenClaw-triggered Astron workflows
  • require HMAC-SHA256 webhook signatures by default, with an explicit unsigned-dev mode for local testing
  • return a structured audit event and workflow-agent dispatch payload, while defaulting high-risk RPA actions to pending human approval
  • add unit tests for approval gating, HMAC verification, and audit context preservation

Closes #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.py
  • git diff --check

@CLAassistant

CLAassistant commented Jun 28, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@potato112212
potato112212 force-pushed the codex/openclaw-secure-trigger branch from 94b36d6 to 91aac46 Compare June 28, 2026 05:13

@gemini-code-assist gemini-code-assist 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.

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.

Comment thread core/agent/api/v1/openclaw_trigger.py Outdated
Comment on lines +36 to +37
except (json.JSONDecodeError, ValidationError) as exc:
return JSONResponse(status_code=422, content={"code": 422, "message": str(exc)})

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.

high

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.

Suggested change
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)})

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in latest head 03bf0ff: the endpoint now catches UnicodeDecodeError and tests/test_openclaw_trigger.py includes test_malformed_utf8_body_returns_422.

@potato112212
potato112212 force-pushed the codex/openclaw-secure-trigger branch 2 times, most recently from 03bf0ff to 8e111b7 Compare June 28, 2026 05:22
Signed-off-by: biqibao112212-bot <277263126+biqibao112212-bot@users.noreply.github.com>
@potato112212
potato112212 force-pushed the codex/openclaw-secure-trigger branch from 8e111b7 to 77bb63a Compare June 28, 2026 05:24
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)})
@lyj715824

Copy link
Copy Markdown
Contributor

This project allows you to export workflows as skills, which can then be directly imported into local agents or Claw for workflow invocation.

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.

✨ Feature Request: 支持 OpenClaw 触发 Astron Agent 调度 RPA 机器人执行安全操作

5 participants