{"record":{"id":"e276ff398c6aed96","repo":"cube-js/cube","slug":"file-not-found-path","errorCode":null,"errorMessage":"file not found: {path}","messagePattern":"file not found: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"rust/cube-cli/src/commands/data_model.rs","lineNumber":384,"sourceCode":"                        println!(\"{path}\");\n                    }\n                }\n            }\n        }\n        Cmd::Get {\n            deployment,\n            path,\n            branch,\n        } => {\n            let mut query: Query = vec![(\"withContent\".into(), \"true\".into())];\n            util::push(&mut query, \"branchName\", &branch);\n            let res = api.get(&base(deployment), &query).await?;\n            let file = tree_nodes(&res).into_iter().find(|f| {\n                same_path(&output::field(f, \"path\"), &path) && output::field(f, \"type\") == \"file\"\n            });\n            match file {\n                Some(f) => print!(\"{}\", output::field(&f, \"content\")),\n                None => anyhow::bail!(\"file not found: {path}\"),\n            }\n        }\n        Cmd::Put {\n            deployment,\n            path,\n            file,\n            content,\n            branch,\n        } => {\n            let text = read_content(file, content)?;\n            let mut map = serde_json::Map::new();\n            map.insert(\"files\".into(), json!([{ \"path\": path, \"content\": text }]));\n            let res = api\n                .put(&base(deployment), Some(&write_body(map, &branch)))\n                .await?;\n            if ctx.json {\n                output::print_json(&res);\n            } else {","sourceCodeStart":366,"sourceCodeEnd":402,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/rust/cube-cli/src/commands/data_model.rs#L366-L402","documentation":"The data-model file read command fetches the repository tree from the deployment API and searches it for the requested path. If no tree node matches the path (and is a file), it fails with 'file not found: {path}'.","triggerScenarios":"Running `cube data-model get --path <p>` where <p> does not exactly match a file path in the deployment's data model repository — wrong case, leading/trailing slash, wrong directory, or the file was deleted.","commonSituations":"Requesting schema files by path from memory instead of listing the tree first; path casing mismatches; querying a branch/deployment where the file doesn't exist yet; paths written with leading './' or absolute prefixes.","solutions":["List available files first (`cube data-model tree` or equivalent) and copy the exact path","Fix the path casing/leading slashes to match the repo-relative path exactly","Verify you are pointed at the correct deployment/branch that contains the file","Commit/push the model file to the deployment's repository if it was recently added"],"exampleFix":"// before\ncube data-model get --path /schema/orders.yml   # leading slash, not found\n// after\ncube data-model get --path schema/orders.yml","handlingStrategy":"validation","validationCode":"const tree = await cube.dataModel.tree({ deployment });\nconst normalized = path.replace(/^\\.?\\//, '');\nif (!tree.some(f => f.type === 'file' && f.path === normalized)) {\n  throw new Error(`'${normalized}' not in deployment tree — list files and use the exact path`);\n}","typeGuard":"function findFileExact(tree: { path: string; type: string }[], p: string) {\n  const norm = p.replace(/^\\.?\\//, '');\n  return tree.find(f => f.type === 'file' && f.path === norm) ?? null;\n}","tryCatchPattern":"try {\n  await getDataModelFile(path);\n} catch (e) {\n  if (/file not found/.test(String(e))) { const tree = await listTree(); console.error('Available:', tree.map(f => f.path)); }\n  throw e;\n}","preventionTips":["Copy paths from `data-model tree` output instead of typing them","Normalize paths: strip leading slashes, match case exactly","Confirm the deployment/branch actually contains the file before fetching","Add a pre-check that searches the tree before requesting file content"],"tags":["cli","files","not-found","user-input"],"backgroundTag":"file-not-found","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}