-
Notifications
You must be signed in to change notification settings - Fork 0
docs: add Prerequisites section, DingTalk contact, and DCO signoff rule #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -9,6 +9,12 @@ | |||||
| 该命令组还提供短别名 `ar sa`。会话子组既可用 `ar sa conv` 也可用 | ||||||
| `ar sa conversation`,行为一致。 | ||||||
|
|
||||||
| > **使用前提:** 执行本页任何命令前,请先完成 | ||||||
| > [前置准备](./index.md#前置准备) 中的两项一次性配置 —— | ||||||
| > 授权 `AliyunAgentRunSuperAgentRole` 角色,并给 AccessKey 挂载 | ||||||
| > `AliyunAgentRunFullAccess` 系统策略。任一项缺失都会以退出码 `3` | ||||||
| > (`AccessDenied`)失败。 | ||||||
|
||||||
| > (`AccessDenied`)失败。 | |
| > (权限/认证错误)失败。 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,6 +27,23 @@ | |
| EXIT_AUTH_ERROR = 3 | ||
| EXIT_SERVER_ERROR = 4 | ||
|
|
||
| PREREQUISITES_HINT = ( | ||
| "Complete the one-time setup at " | ||
| "https://github.com/Serverless-Devs/agentrun-cli#prerequisites — " | ||
| "authorize the AliyunAgentRunSuperAgentRole and grant " | ||
| "AliyunAgentRunFullAccess to your AccessKey." | ||
| ) | ||
|
|
||
| _AUTH_PATTERNS = ( | ||
| "Forbidden", | ||
| "InvalidAccessKey", | ||
| "SignatureDoesNotMatch", | ||
| "AccessDenied", | ||
| "NoPermission", | ||
| "AliyunAgentRunSuperAgentRole", | ||
| "EntityNotExist.Role", | ||
| ) | ||
|
|
||
|
|
||
| def handle_errors(func: Callable) -> Callable: | ||
| """Decorator that catches common SDK / HTTP errors and exits cleanly.""" | ||
|
|
@@ -52,8 +69,8 @@ def wrapper(*args, **kwargs): | |
| if "ResourceAlreadyExistError" in exc_type or "AlreadyExist" in exc_type: | ||
| echo_error("ResourceAlreadyExists", msg) | ||
| sys.exit(EXIT_BAD_INPUT) | ||
| if "Forbidden" in msg or "InvalidAccessKey" in msg or "SignatureDoesNotMatch" in msg: | ||
| echo_error("AuthenticationFailed", msg) | ||
| if any(pattern in msg for pattern in _AUTH_PATTERNS): | ||
| echo_error("AuthenticationFailed", msg, hint=PREREQUISITES_HINT) | ||
| sys.exit(EXIT_AUTH_ERROR) | ||
|
Comment on lines
+72
to
74
|
||
|
|
||
| # Generic fallback | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -92,9 +92,13 @@ def format_output(ctx: click.Context, data: Any, quiet_field: Optional[str] = No | |||||
| echo_json(data) | ||||||
|
|
||||||
|
|
||||||
| def echo_error(error_type: str, message: str) -> None: | ||||||
| """Write a structured JSON error to stderr.""" | ||||||
| click.echo( | ||||||
| json.dumps({"error": error_type, "message": message}, ensure_ascii=False), | ||||||
| err=True, | ||||||
| ) | ||||||
| def echo_error(error_type: str, message: str, hint: Optional[str] = None) -> None: | ||||||
| """Write a structured JSON error to stderr. | ||||||
|
|
||||||
| When *hint* is provided it is included as a ``hint`` field in the JSON | ||||||
| payload — used to surface Prerequisites links on permission failures. | ||||||
| """ | ||||||
| payload: dict = {"error": error_type, "message": message} | ||||||
| if hint: | ||||||
|
||||||
| if hint: | |
| if hint is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This note says missing prerequisites surfaces as exit code
3(AccessDenied), but the code now also treats other permission/role messages (e.g.NoPermission,EntityNotExist.Role) as exit code 3. Consider rewording to avoid implying the stderr message is alwaysAccessDenied(e.g. “exit code 3 (authentication/permission error)”).