{"record":{"id":"b1a9815d62cabc4c","repo":"cross-rs/cross","slug":"refusing-to-push-without-tag-or-branch-specify-a-repository","errorCode":null,"errorMessage":"Refusing to push without tag or branch. Specify a repository and tag with `--repository <repository> --tag <tag>`","messagePattern":"Refusing to push without tag or branch\\. Specify a repository and tag with `--repository <repository> --tag <tag>`","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xtask/src/build_docker_image.rs","lineNumber":241,"sourceCode":"            msg_info.fatal(\"cannot specify `--no-output` with engine that does not support the `--output` flag\", 1);\n        } else if has_buildkit {\n            docker_build.arg(\"--load\");\n        }\n\n        let mut tags = vec![];\n\n        match (ref_type.as_deref(), ref_name.as_deref()) {\n            (Some(ref_type), Some(ref_name)) => tags.extend(determine_image_name(\n                target,\n                &repository,\n                ref_type,\n                ref_name,\n                is_latest,\n                &version,\n            )?),\n            _ => {\n                if push && tag_override.is_none() {\n                    panic!(\n                        \"Refusing to push without tag or branch. Specify a repository and tag with `--repository <repository> --tag <tag>`\"\n                    )\n                }\n                tags.push(target.image_name(&repository, \"local\"));\n            }\n        }\n\n        if let Some(ref tag) = tag_override {\n            tags = vec![target.image_name(&repository, tag)];\n        }\n\n        if engine.kind.supports_pull_flag() {\n            docker_build.arg(\"--pull\");\n        }\n        let base_name = format!(\"{repository}/{}\", target.name);\n        if no_cache {\n            docker_build.arg(\"--no-cache\");\n        } else if engine.kind.supports_cache_from_type() {","sourceCodeStart":223,"sourceCodeEnd":259,"githubUrl":"https://github.com/cross-rs/cross/blob/8c1a8aa4b661711f4b7b6ac07c2e8929ce2f7d27/xtask/src/build_docker_image.rs#L223-L259","documentation":"The `build_docker_image` xtask refuses to push a Docker image when the build was triggered from a ref that is neither a tag nor a branch AND an explicit `--tag` override was not supplied. Pushing from such a ref would produce an ambiguous/unintended image tag, so it panics as a safety check.","triggerScenarios":"Running the xtask with `push = true` while `ref_name` matches none of the tag/branch release cases and neither `--tag` (tag_override) nor a recognizable branch/tag ref is provided — e.g. building/pushing from a detached HEAD, a PR ref, or an arbitrary commit.","commonSituations":"CI pipelines that trigger on merge queues or detached checkouts, manually running the xtask locally with a push flag enabled, or pushing from a commit SHA ref without specifying repository/tag.","solutions":["Pass an explicit `--repository <repository> --tag <tag>` to the xtask invocation.","Run the build from a proper tag or branch ref so the release-tagging path is selected.","If this is a local test build, drop the push flag so the image is only tagged `local`."],"exampleFix":"// before\ncargo xtask build-docker-image --push  # on detached HEAD\n// after\ncargo xtask build-docker-image --push --repository myrepo --tag v1.2.3","handlingStrategy":"validation","validationCode":"if push && tag_override.is_none() && !is_tag_or_branch_ref(ref_name) {\n    return Err(\"refusing to push: supply --repository/--tag or run from a tag/branch\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only enable push in CI jobs triggered by tag or branch refs.","Always pass --repository and --tag when pushing from non-release refs.","Check CI checkout mode: use fetch-depth/full checkout so branch info is present, avoiding detached HEAD."],"tags":["docker","ci","push-safety","cli"],"backgroundTag":"missing-required-argument","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"}