{"record":{"id":"f7b2a8328d24e7f2","repo":"astrid-runtime/astrid","slug":"timeout-exceeds-upper-bound-timeout-secs-upper-b","errorCode":null,"errorMessage":"timeout exceeds upper bound ({TIMEOUT_SECS_UPPER_BOUND}s)","messagePattern":"timeout exceeds upper bound \\((.+?)s\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-cli/src/commands/quota.rs","lineNumber":305,"sourceCode":"    let mut client = crate::admin_client::connect_as_active_agent().await?;\n    let body = client\n        .request(AdminRequestKind::QuotaGet {\n            principal: target.clone(),\n        })\n        .await?;\n    let body = into_result(body)?;\n    let mut quotas = match body {\n        AdminResponseBody::Quotas(q) => q,\n        other => anyhow::bail!(\"unexpected response from kernel: {other:?}\"),\n    };\n    if let Some(s) = args.memory.as_deref() {\n        quotas.max_memory_bytes = parse_bytes(s).context(\"invalid --memory\")?;\n    }\n    if let Some(s) = args.timeout.as_deref() {\n        let d = parse_duration(s).context(\"invalid --timeout\")?;\n        quotas.max_timeout_secs = d.as_secs().max(1);\n        if quotas.max_timeout_secs > TIMEOUT_SECS_UPPER_BOUND {\n            anyhow::bail!(\"timeout exceeds upper bound ({TIMEOUT_SECS_UPPER_BOUND}s)\");\n        }\n    }\n    if let Some(s) = args.storage.as_deref() {\n        quotas.max_storage_bytes = parse_bytes(s).context(\"invalid --storage\")?;\n    }\n    if let Some(n) = args.processes {\n        if n > BACKGROUND_PROCESSES_UPPER_BOUND {\n            anyhow::bail!(\"processes exceeds upper bound ({BACKGROUND_PROCESSES_UPPER_BOUND})\");\n        }\n        quotas.max_background_processes = n;\n    }\n    if let Some(s) = args.ipc_rate.as_deref() {\n        quotas.max_ipc_throughput_bytes = parse_bytes(s).context(\"invalid --ipc-rate\")?;\n    }\n    let body = client\n        .request(AdminRequestKind::QuotaSet {\n            principal: target.clone(),\n            quotas,","sourceCodeStart":287,"sourceCodeEnd":323,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-cli/src/commands/quota.rs#L287-L323","documentation":"run_set parses the --timeout duration and stores it as quotas.max_timeout_secs (floored at 1s); if the resulting seconds exceed TIMEOUT_SECS_UPPER_BOUND it bails with this error. The library enforces a kernel-side upper limit on the max timeout quota to prevent absurdly long-running workloads.","triggerScenarios":"Running the quota set command with --timeout whose duration, converted to whole seconds, exceeds TIMEOUT_SECS_UPPER_BOUND (e.g. `--timeout 100h` when the bound is far smaller). Only raised when --timeout is provided.","commonSituations":"Developer assumes durations are unbounded and passes days/hours; unit confusion (writing a large number of seconds thinking it is milliseconds, or vice versa); copying an old config where a previously legal timeout now exceeds a tightened bound.","solutions":["Lower the --timeout value below TIMEOUT_SECS_UPPER_BOUND (check the constant's current value in quota.rs).","Verify the unit: the flag parses durations, so use e.g. `--timeout 30s` / `30m` rather than raw large numbers.","If the workload genuinely needs longer timeouts, raise TIMEOUT_SECS_UPPER_BOUND (and the kernel's matching limit) deliberately in code.","Clamp or validate the duration in the invoking script before calling the CLI to fail early with a clearer message."],"exampleFix":"// before\nastrid quota set --principal agent-7 --timeout 48h   // bails: exceeds upper bound\n// after\nastrid quota set --principal agent-7 --timeout 30m   // within TIMEOUT_SECS_UPPER_BOUND","handlingStrategy":"validation","validationCode":"// validate the requested timeout against the bound before invoking quota set\nconst TIMEOUT_SECS_UPPER_BOUND: u64 = 3600;\nlet d = humantime::parse_duration(\"30m\")?;\nlet secs = d.as_secs().max(1);\nif secs > TIMEOUT_SECS_UPPER_BOUND {\n    anyhow::bail!(\"--timeout {secs}s exceeds upper bound ({TIMEOUT_SECS_UPPER_BOUND}s)\");\n}","typeGuard":null,"tryCatchPattern":"match run_set(args).await {\n    Err(e) if e.to_string().contains(\"timeout exceeds upper bound\") => {\n        eprintln!(\"--timeout too large; must be <= TIMEOUT_SECS_UPPER_BOUND seconds\");\n        ExitCode::from(2) // usage error, not runtime failure\n    },\n    other => other,\n}","preventionTips":["Check TIMEOUT_SECS_UPPER_BOUND in quota.rs before choosing --timeout values.","Use explicit duration units (30s, 30m) to avoid second/millisecond confusion.","Clamp or pre-validate durations in wrapper scripts so failures happen before the IPC round trip.","If longer timeouts are genuinely needed, raise the bound (and the kernel-side limit) in a deliberate change, not ad hoc."],"tags":["quota","validation","timeout","cli-argument","rust"],"backgroundTag":"value-out-of-range","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}