Google API errors as typed findings, never raw JSON: cli/lib/google-errors.ts parses SERVICE_DISABLED (api-disabled: service, Cloud project, console page), PERMISSION_DENIED (no-app-access: which app, Users and permissions), 401 / invalid_grant (auth-revoked) and 429 (quota); health / analytics print one line with the URL, raw text in detail and the log; desktop Health tab: the line, 'Turn it on in Google Cloud' and 'Check again', raw text in a collapsed Details; Portfolio shows a Cloud project blocking several apps once. Findings exit codes are results: the sidecar reports outcome (ok / findings / declined / failed) and the command's own error line; scan / check / validate / health exit 1 with findings show and cache the findings; no bare 'Exit code N' anywhere. tests/google-errors.test.ts, boot check errors cases (api-disabled, scan-findings, scan-failed) (pitfall 57)
This commit is contained in:
parent
f69c10d3a0
commit
89256f1e80
28 changed files with 666 additions and 47 deletions
20
apps/desktop/src/lib/results.ts
Normal file
20
apps/desktop/src/lib/results.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// What a command's result means for the window: exit 1 of scan / check / validate / health with the --json result
|
||||
// printed is "found problems" (shown as the findings), 3 is "declined"; only a real failure is an error, and then in
|
||||
// the command's own words (its error line, Google errors as one plain line), never a bare "Exit code N".
|
||||
import { errorLine, type Outcome, outcomeOf, type ToolResult } from '../../../../cli/lib/desktop-protocol';
|
||||
import { plainError } from '../../../../cli/lib/google-errors';
|
||||
import { t } from '../i18n';
|
||||
|
||||
export function outcome(method: string, r: Pick<ToolResult, 'exitCode' | 'data' | 'outcome'>): Outcome {
|
||||
return r.outcome ?? outcomeOf(method, r.exitCode, r.data !== undefined);
|
||||
}
|
||||
|
||||
/** The result carries data the screen can show (ok, or findings). */
|
||||
export const usable = (method: string, r: Pick<ToolResult, 'exitCode' | 'data' | 'outcome'>): boolean =>
|
||||
r.data !== undefined && ['ok', 'findings'].includes(outcome(method, r));
|
||||
|
||||
/** A failed run in words: the command's error line (Google JSON bodies as one plain line). */
|
||||
export function failureText(r: Pick<ToolResult, 'exitCode' | 'output' | 'error'>): string {
|
||||
const line = r.error || errorLine('', r.output ?? '');
|
||||
return line ? plainError(line) : t('common.exitNoMessage', { code: r.exitCode });
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue