{"record":{"id":"8619d4ed503b510a","repo":"cross-rs/cross","slug":"no-valid-choice-to-pick-for-image-name","errorCode":null,"errorMessage":"no valid choice to pick for image name","messagePattern":"no valid choice to pick for image name","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xtask/src/build_docker_image.rs","lineNumber":434,"sourceCode":"        }\n        (\"branch\", ref_name) => {\n            if let Some(gh_queue) = ref_name.strip_prefix(\"gh-readonly-queue/\") {\n                let (_, source) = gh_queue\n                    .split_once('/')\n                    .ok_or_else(|| eyre::eyre!(\"invalid gh-readonly-queue branch name\"))?;\n                tags.push(target.image_name(repository, source));\n            } else {\n                tags.push(target.image_name(repository, ref_name));\n            }\n\n            if [\"staging\", \"trying\"]\n                .iter()\n                .any(|branch| branch != &ref_name)\n            {\n                tags.push(target.image_name(repository, \"edge\"));\n            }\n        }\n        _ => eyre::bail!(\"no valid choice to pick for image name\"),\n    }\n    Ok(tags)\n}\n\npub fn job_summary(\n    results: &[Result<ImageTarget, (ImageTarget, eyre::ErrReport)>],\n) -> cross::Result<String> {\n    let mut summary = \"# SUMMARY\\n\\n\".to_string();\n    let success: Vec<_> = results.iter().filter_map(|r| r.as_ref().ok()).collect();\n    let errors: Vec<_> = results.iter().filter_map(|r| r.as_ref().err()).collect();\n\n    if !success.is_empty() {\n        summary.push_str(\"## Success\\n\\n| Target |\\n| ------ |\\n\");\n    }\n\n    for target in success {\n        writeln!(summary, \"| {} |\", target.alt())?;\n    }","sourceCodeStart":416,"sourceCodeEnd":452,"githubUrl":"https://github.com/cross-rs/cross/blob/8c1a8aa4b661711f4b7b6ac07c2e8929ce2f7d27/xtask/src/build_docker_image.rs#L416-L452","documentation":"determine_image_name builds the list of Docker image tags from the current git ref. The match on the ref type (tag, branch, etc.) has no arm covering the encountered ref, so the function bails with this error. It means the CI/git state does not correspond to any tag or recognized branch form the tool knows how to name an image for.","triggerScenarios":"Calling build_docker_image when the current git ref is neither a tag nor a branch pattern matched above (e.g. detached HEAD, an unusual ref like refs/notes/*, or running locally where the ref resolution returns an unmatched variant).","commonSituations":"Running the xtask docker build outside the expected CI environment (no tag/branch context), or a new CI ref type appearing after a CI system change.","solutions":["Run the build from a proper git tag or branch checkout so the ref matches a known arm","Check `git rev-parse --symbolic-full-name HEAD` and confirm it resolves to refs/heads/* or refs/tags/*","Add a match arm for the new ref type (e.g. default to repository name) in determine_image_name"],"exampleFix":"// before\n_ => eyre::bail!(\"no valid choice to pick for image name\"),\n// after\n_ => {\n    tags.push(target.image_name(repository, \"local\"));\n}","handlingStrategy":"validation","validationCode":"let r = std::process::Command::new(\"git\").args([\"rev-parse\",\"--symbolic-full-name\",\"HEAD\"]).output()?;\nlet name = String::from_utf8_lossy(&r.stdout).trim().to_string();\nif !(name.starts_with(\"refs/heads/\") || name.starts_with(\"refs/tags/\")) {\n    anyhow::bail!(\"build must run from a branch or tag ref, got: {name}\");\n}","typeGuard":"fn is_supported_ref(full_name: &str) -> bool {\n    full_name.starts_with(\"refs/heads/\") || full_name.starts_with(\"refs/tags/\")\n}","tryCatchPattern":null,"preventionTips":["Only run image builds in CI on branch push or tag events","Fail fast at pipeline start if the git ref is detached or unrecognized","Keep the ref-type match and CI event types in sync when changing CI providers"],"tags":["docker","git","ci","build"],"backgroundTag":"unsupported-operation","analyzedSha":"8c1a8aa4b661711f4b7b6ac07c2e8929ce2f7d27","analyzedAt":"2026-09-13T15:10:43.988Z","contentChangedAt":"2026-09-13T15:10:43.988Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}