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
|
|
@ -205,7 +205,7 @@ pub async fn sidecar_call(window: WebviewWindow, app: AppHandle, state: State<'_
|
|||
o.insert("credentials".into(), Value::Object(creds));
|
||||
}
|
||||
let res = r.call_job(&method, p, job.as_deref()).await?;
|
||||
if res["ok"] == Value::Bool(true) && !res["data"].is_null() {
|
||||
if readable(&res) {
|
||||
let _ = state.cache.put(&id, &method, &args, &res, &store::now_iso());
|
||||
}
|
||||
return Ok(res);
|
||||
|
|
@ -223,13 +223,19 @@ pub async fn sidecar_call(window: WebviewWindow, app: AppHandle, state: State<'_
|
|||
let res = r.call_job(&method, p, job.as_deref()).await?;
|
||||
if let Some(id) = cache_project {
|
||||
// only results that read something: a failed store read must not hide the last good one
|
||||
if res["ok"] == Value::Bool(true) && !res["data"].is_null() {
|
||||
if readable(&res) {
|
||||
let _ = state.cache.put(&id, &method, &args, &res, &store::now_iso());
|
||||
}
|
||||
}
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
/// A result worth caching: it carries data and is ok, or "findings" (scan / check / validate / health exit 1 with their
|
||||
/// result printed: by design, not a failure). A failed read must not hide the last good one.
|
||||
fn readable(res: &Value) -> bool {
|
||||
!res["data"].is_null() && (res["ok"] == Value::Bool(true) || res["outcome"] == Value::String("findings".into()))
|
||||
}
|
||||
|
||||
/// The last cached result of a read (`project_id` "*" for the portfolio), with its time; null when never read.
|
||||
#[tauri::command]
|
||||
pub fn cache_get(window: WebviewWindow, state: State<'_, AppState>, method: String, project_id: String, args: Option<Value>) -> Res<Option<Entry>> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue