{"record":{"id":"b9b437c3adb387ff","repo":"gitbutlerapp/gitbutler","slug":"known-statically","errorCode":null,"errorMessage":"known statically","messagePattern":"known statically","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"info","filePath":"crates/but-workspace/src/branch/apply.rs","lineNumber":359,"sourceCode":"        );\n    }\n    // In general, we only have to deal with one branch to apply. But when we are on an adhoc workspace,\n    // we need to assure both branches go into the existing or the new workspace:\n    //  - the current one and the one to apply, if these are different.\n    // The returned workspace ref name will be set to the new merge commit, if created, or it may not change\n    // at all if the workspace can be created by just setting metadata.\n    let (workspace_ref_name_to_update, branches_to_apply) = match &ws.kind {\n        WorkspaceKind::Managed { ref_info }\n        | WorkspaceKind::ManagedMissingWorkspaceCommit { ref_info } => {\n            (ref_info.ref_name.clone(), vec![branch.clone()])\n        }\n        WorkspaceKind::AdHoc => {\n            // We need to switch over to a possibly existing workspace.\n            // We know that the current branch is *not* reachable from the workspace or isn't naturally included,\n            // so it needs to be added as well.\n            let next_ws_ref_name = match workspace_reference_naming {\n                WorkspaceReferenceNaming::Default => {\n                    gix::refs::FullName::try_from(WORKSPACE_REF_NAME).expect(\"known statically\")\n                }\n                WorkspaceReferenceNaming::Given(name) => name,\n            };\n            let mut current_unmanaged_head_branch_name = ws.ref_name().map(|rn| rn.to_owned());\n            if let Some(ref current_head_ref) = current_unmanaged_head_branch_name {\n                // If our current branch is related to the next workspace's target, don't add it to the\n                // soon-to-be-created workspace.\n                // This is a 'trick' to allow callers to prevent 'main' to be added to the workspace automatically\n                // even though the new workspace is supposed to have it as target.\n                if ws.is_branch_the_target_or_its_local_tracking_branch(current_head_ref.as_ref()) {\n                    current_unmanaged_head_branch_name.take();\n                }\n            }\n\n            (\n                next_ws_ref_name,\n                current_unmanaged_head_branch_name\n                    .into_iter()","sourceCodeStart":341,"sourceCodeEnd":377,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but-workspace/src/branch/apply.rs#L341-L377","documentation":"Panic from `expect(\"known statically\")` after `gix::refs::FullName::try_from(WORKSPACE_REF_NAME)` in `apply.rs:359` (but-workspace). It parses a compile-time constant (the default GitButler workspace ref name) into a validated `FullName`. Because the constant is fixed and valid, the conversion cannot fail in a released build; the expect is a compile-time-known invariant, not a runtime risk.","triggerScenarios":"Only fires if `WORKSPACE_REF_NAME` is edited to a string that is not a valid fully-qualified ref name (empty, missing the `refs/` prefix, containing invalid bytes or `..`); applying a branch when the workspace kind is `AdHoc` and `WorkspaceReferenceNaming::Default` is used, which is the normal path that executes this parse.","commonSituations":"Forks that rename the workspace ref constant; patching the constant via a config value at build time; none in stock GitButler.","solutions":["No action needed for stock GitButler — this cannot fire with the shipped constant","If you forked and changed WORKSPACE_REF_NAME, validate it is a fully-qualified ref like `refs/gitbutler/workspace` and covered by a unit test","Prefer `WorkspaceReferenceNaming::Given(name)` at the API boundary instead of editing the constant"],"exampleFix":"// before\nconst WORKSPACE_REF_NAME: &str = \"refs/heads/gitbutler/workspace\"; // valid\n\n// after: guard forks with a test\n#[test]\nfn workspace_ref_name_is_valid() {\n    gix::refs::FullName::try_from(WORKSPACE_REF_NAME).expect(\"known statically\");\n}","handlingStrategy":"validation","validationCode":"// Only relevant for forks that change the constant:\n#[test]\nfn default_workspace_ref_name_parses() {\n    assert!(gix::refs::FullName::try_from(WORKSPACE_REF_NAME).is_ok());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use WorkspaceReferenceNaming::Given(name) to customize ref names instead of editing the constant","Cover any changed constant with a parse test"],"tags":["rust","panic","expect","git-ref-name","static-constant","workspace","gix"],"backgroundTag":"git-ref-name-parse-failure","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}