{"record":{"id":"4bde4acdbdae327a","repo":"gitbutlerapp/gitbutler","slug":"statically-known","errorCode":null,"errorMessage":"statically known","messagePattern":"statically known","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"info","filePath":"crates/but-workspace/src/ref_info.rs","lineNumber":902,"sourceCode":"    if !is_workspace_ref_name(name) {\n        return Ok(None);\n    }\n\n    let md = meta.workspace(name)?;\n    Ok(if md.is_default() {\n        None\n    } else {\n        Some((*md).clone())\n    })\n}\n\n/// Like [`workspace_data_of_workspace_branch()`], but it will try the name of the default GitButler workspace branch.\npub(crate) fn workspace_data_of_default_workspace_branch(\n    meta: &impl but_core::RefMetadata,\n) -> anyhow::Result<Option<but_core::ref_metadata::Workspace>> {\n    workspace_data_of_workspace_branch(\n        meta,\n        WORKSPACE_REF_NAME.try_into().expect(\"statically known\"),\n    )\n}\n\n#[cfg(test)]\nmod review_association_tests {\n    use std::collections::HashMap;\n\n    use super::{apply_review_to_metadata, forge_review_for_branch};\n    use but_core::ref_metadata::Branch;\n\n    fn branch_with_review(review: Option<usize>) -> Branch {\n        let mut branch = Branch::default();\n        branch.review.pull_request = review;\n        branch\n    }\n\n    #[test]\n    fn managed_segment_gets_the_matched_review() {","sourceCodeStart":884,"sourceCodeEnd":920,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but-workspace/src/ref_info.rs#L884-L920","documentation":"workspace_data_of_default_workspace_branch() converts the compile-time constant WORKSPACE_REF_NAME (\"refs/heads/gitbutler/workspace\", but-core/src/lib.rs:128) into a validated gix ref name via try_into().expect(\"statically known\"). The conversion into a gix::refs::FullName/FullNameRef only fails for syntactically invalid ref names, and the constant is valid, so this expect is an unreachable invariant rather than a runtime condition. A panic here means someone edited WORKSPACE_REF_NAME to a string git rejects.","triggerScenarios":"Calling workspace_data_of_default_workspace_branch(&metadata) on any but-workspace RefInfo computation. The panic fires only if WORKSPACE_REF_NAME is changed to a value gix::refs::FullName::try_from rejects: empty string, spaces, backslashes, control characters, or a non-fully-qualified name like \"workspace\".","commonSituations":"Refactors renaming the workspace ref constant, or copying this expect pattern onto a new, runtime-supplied ref name that is not statically guaranteed. No CLI/API input can trigger it as shipped.","solutions":["Keep WORKSPACE_REF_NAME a valid fully-qualified ref (refs/heads/gitbutler/workspace); if you changed it, revert or fix the value","Add a unit test asserting gix::refs::FullName::try_from(WORKSPACE_REF_NAME).is_ok() so an invalid constant fails CI instead of panicking at runtime","If the ref name must come from configuration, use the fallible form like but-api does: meta.workspace(WORKSPACE_REF_NAME.try_into()?)?"],"exampleFix":"// before\nWORKSPACE_REF_NAME.try_into().expect(\"statically known\")\n\n// after - validate the constant once in a test instead of asserting on every call\n#[test]\nfn workspace_ref_name_is_valid() {\n    gix::refs::FullName::try_from(but_core::WORKSPACE_REF_NAME).unwrap();\n}","handlingStrategy":"validation","validationCode":"// Verify the constant still parses before relying on the invariant (run in CI)\n#[test]\nfn workspace_ref_name_is_valid() {\n    assert!(\n        gix::refs::FullName::try_from(but_core::WORKSPACE_REF_NAME).is_ok(),\n        \"WORKSPACE_REF_NAME must remain a valid fully-qualified ref\"\n    );\n}","typeGuard":"fn is_valid_workspace_ref(name: &str) -> bool {\n    gix::refs::FullName::try_from(name).is_ok()\n}","tryCatchPattern":null,"preventionTips":["Never apply this expect pattern to runtime-supplied ref names - use .try_into()? instead","Keep a unit test that parses every ref-name constant used with expect","Prefer the fallible APIs already used elsewhere, e.g. meta.workspace(WORKSPACE_REF_NAME.try_into()?)?"],"tags":["rust","invariant","git-refs","workspace","panic"],"backgroundTag":"invalid-git-ref-name","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}