-
Notifications
You must be signed in to change notification settings - Fork 88
fix(#2528): sync VALID_ROLES with Go's ValidRoles() #6369
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
71ead5b
2477d8d
bc588ce
1edfda5
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,11 +9,11 @@ export type OrgConfigYaml = { | |
| max_implementation_retries?: number; | ||
| auto_merge?: boolean; | ||
| }; | ||
| agents?: { role: string; name?: string; slug?: string }[]; | ||
| agents?: (string | { source?: string; name?: string; enabled?: boolean })[]; | ||
| repos?: Record<string, { enabled?: boolean; roles?: string[] }>; | ||
| }; | ||
|
|
||
| const VALID_ROLES = new Set(["fullsend", "triage", "coder", "review"]); | ||
| const VALID_ROLES = new Set(["fullsend", "triage", "coder", "review", "fix", "retro", "prioritize", "e2e"]); | ||
|
|
||
| /** 512 KiB — more than sufficient for any realistic org `config.yaml`. */ | ||
| export const MAX_ORG_CONFIG_YAML_UTF8_BYTES = 512 * 1024; | ||
|
|
@@ -111,12 +111,9 @@ function assertOrgConfigShape(doc: Record<string, unknown>): void { | |
| } | ||
| for (let i = 0; i < doc.agents.length; i++) { | ||
| const el = doc.agents[i]; | ||
| if (typeof el === "string") continue; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MEDIUM — Removed This PR deletes the only type assertion on agent fields ( Reproduced by running the shipped helpers in Node: a YAML For accuracy: the neighbouring case of a non-string Related: a quoted Suggestion: In |
||
| if (el === null || typeof el !== "object" || Array.isArray(el)) { | ||
| throw new Error(`parsing org config: agents[${i}] must be a mapping with a string role`); | ||
| } | ||
| const role = (el as Record<string, unknown>).role; | ||
| if (typeof role !== "string") { | ||
| throw new Error(`parsing org config: agents[${i}].role must be a string`); | ||
| throw new Error(`parsing org config: agents[${i}] must be a string or mapping`); | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -153,20 +150,15 @@ export function validateOrgConfig(cfg: OrgConfigYaml): string | null { | |
| } | ||
| for (const role of cfg.defaults?.roles ?? []) { | ||
| if (!VALID_ROLES.has(role)) { | ||
| return `invalid role ${JSON.stringify(role)}: must be one of fullsend, triage, coder, review`; | ||
| } | ||
| } | ||
| for (const agent of cfg.agents ?? []) { | ||
| if (!VALID_ROLES.has(agent.role)) { | ||
| return `invalid agent role ${JSON.stringify(agent.role)}: must be one of fullsend, triage, coder, review`; | ||
| return `invalid role ${JSON.stringify(role)}: must be one of fullsend, triage, coder, review, fix, retro, prioritize, e2e`; | ||
| } | ||
| } | ||
| return null; | ||
| } | ||
|
|
||
| /** Agent rows for secrets-layer analyze (mirrors `config.OrgConfig.Agents`). */ | ||
| export function agentsFromConfig(cfg: OrgConfigYaml): { role: string }[] { | ||
| return (cfg.agents ?? []).map((a) => ({ role: a.role })); | ||
| /** Roles for secrets-layer analyze — Go keys secrets by role, not agent name. */ | ||
| export function rolesFromConfig(cfg: OrgConfigYaml): { role: string }[] { | ||
| return (cfg.defaults?.roles ?? []).map((r) => ({ role: r })); | ||
| } | ||
|
|
||
| /** Enabled repo names for enrollment-layer analyze (sorted). */ | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.