{"record":{"id":"6fdc2d30c23c0e9e","repo":"xai-org/grok-build","slug":"expired","errorCode":null,"errorMessage":"expired","messagePattern":"expired","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-file-utils/src/queue.rs","lineNumber":1934,"sourceCode":"    stats: &Arc<UploadQueueStats>,\n    consecutive_failures: &Arc<AtomicU32>,\n    draining: &Arc<std::sync::atomic::AtomicBool>,\n    mut permit: Option<ConcurrencyPermit>,\n) {\n    let size = file_size(item.source.path());\n    let accounted_bytes = item.source.disk_bytes(size);\n    stats.inflight.fetch_add(1, Ordering::Relaxed);\n    stats.notify_transition();\n    if item.enqueued_at.elapsed() > retry_policy.max_age {\n        tracing::warn!(\n            age_secs = item.enqueued_at.elapsed().as_secs(),\n            outcome = \"expired\",\n            \"Dropping expired upload queue item\"\n        );\n        remove_item_files(&item, Some(stats));\n        stats.failed.fetch_add(1, Ordering::Relaxed);\n        settle_pending(stats, accounted_bytes);\n        notify_completion(&mut item, Err(anyhow::anyhow!(\"expired\")));\n        return;\n    }\n    let result = upload_with_retries(\n        &mut item,\n        resolver,\n        retry_policy,\n        size,\n        stats,\n        draining,\n        permit.as_mut(),\n    )\n    .await;\n    match result {\n        Ok((url, compression, stored_size)) => {\n            let compressed = matches!(compression, BlobCompression::Zstd);\n            tracing::info!(\n                attempts = item.attempts,\n                size_bytes = size,","sourceCodeStart":1916,"sourceCodeEnd":1952,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-file-utils/src/queue.rs#L1916-L1952","documentation":"This error is raised when an upload queue item exceeds the retry policy's max_age and is dropped as expired. The worker removes the item's files, marks it failed in stats, settles any accounted bytes, and delivers this error to the item's completion channel. It means the upload never succeeded within its allowed lifetime and was intentionally discarded.","triggerScenarios":"An upload retrying repeatedly due to transient network failures or 401 auth outages until enqueued_at.elapsed() reaches policy.max_age; a queue worker processing a deeply backlogged item whose deadline already passed; extremely long retry backoff configurations exceeding max_age.","commonSituations":"Prolonged credential outage (401 parking) that outlasts the item's max age; sustained network partition while the queue keeps retrying; misconfigured max_age too short for large-file uploads; service suspension that lets queued items age out.","solutions":["Increase the retry policy's max_age so long-running uploads are not expired during outages.","Monitor queue stats.failed and completion receivers; re-enqueue dropped items after the transient issue resolves.","Shorten wait_for_network_retry backoff or cap attempts so items finish within max_age.","Fix the underlying auth/network problem quickly; the queue intentionally gives up at max_age."],"exampleFix":"// before\nlet policy = RetryPolicy { max_age: Duration::from_secs(300), .. };\n\n// after\nlet policy = RetryPolicy { max_age: Duration::from_secs(3600), .. };","handlingStrategy":"retry","validationCode":"// Ensure the retry budget fits the worst-case queue wait\nif policy.max_age < retry_policy.backoff * (retry_policy.max_retries as u32) {\n    anyhow::bail!(\"max_age too small for retry policy; items will expire\");\n}","typeGuard":null,"tryCatchPattern":"// Treat expiration as a skip-and-re-enqueue\nmatch completion_rx.await {\n    Ok(url) => use_url(url),\n    Err(e) if e.to_string() == \"expired\" => {\n        tracing::warn!(\"upload expired; re-enqueueing\");\n        queue.enqueue(item).await?;\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Size max_age generously relative to retry backoff and expected outage lengths.","Monitor stats.failed for spikes indicating mass expiry.","Fix auth/network incidents quickly; parked items age out.","Alert on queue depth so backlog does not exceed item lifetimes."],"tags":["rust","upload-queue","timeout","retry-policy","expired"],"backgroundTag":"upload-item-expired","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}