{"record":{"id":"7424b73b6e66e12b","repo":"BoundaryML/baml","slug":"dependency-name-name-is-reserved","errorCode":null,"errorMessage":"dependency name `{name}` is reserved","messagePattern":"dependency name `(.+?)` is reserved","errorType":"exception","errorClass":"SourceRootError","httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_db/src/db.rs","lineNumber":91,"sourceCode":"\n    #[must_use]\n    pub fn depending_on(mut self, dependencies: Vec<Dependency>) -> Self {\n        self.dependencies = dependencies;\n        self\n    }\n}\n\n/// Why [`ProjectDatabase::add_source_root`] or\n/// [`ProjectDatabase::add_dependency`] refused.\n#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]\npub enum SourceRootError {\n    /// A live root already sits at this (canonical) path.\n    #[error(\"a source root already exists at this path\")]\n    PathTaken(SourceRoot),\n    /// The edge name is one no package may declare: a stdlib package's name\n    /// (already an implicit edge of every package) or a source-level\n    /// qualifier (`root`, `env`).\n    #[error(\"dependency name `{name}` is reserved\")]\n    ReservedDependencyName { name: Name },\n    /// The root already has an edge under this name.\n    #[error(\"dependency `{name}` is declared twice\")]\n    DuplicateDependencyName { name: Name },\n    /// The edge names a root that is not live in this database.\n    #[error(\"dependency `{name}` names a source root that does not exist\")]\n    UnknownDependencyRoot { name: Name },\n    /// The edge would make the dependency graph cyclic.\n    #[error(\"dependency `{name}` would form a dependency cycle\")]\n    DependencyCycle { name: Name },\n    /// The interface bytes are not a valid `PackageInterface` artifact.\n    #[error(\"invalid package interface: {message}\")]\n    InvalidInterface { message: String },\n}\n\n/// The main database for BAML projects.\n///\n/// `ProjectDatabase` owns the Salsa storage directly and implements all the","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_db/src/db.rs#L73-L109","documentation":"SourceRootError::ReservedDependencyName is returned by ProjectDatabase::add_dependency when the edge name is one no package may declare: a stdlib package's name (already an implicit dependency edge of every package) or a source-level qualifier like `root` or `env`. The database reserves these names to keep name resolution unambiguous.","triggerScenarios":"Calling add_dependency(root, name, path) where name is a stdlib package name or \"root\"/\"env\"; or a build tool deriving dependency edges from a manifest that declares a dependency with one of these reserved identifiers.","commonSituations":"A project file or manifest that names a local package the same as a stdlib package (e.g. `math`, `gen`) or uses `root`/`env` as a dependency key; build scripts auto-registering dependencies from directory names that collide.","solutions":["Rename the dependency edge to a non-reserved name (avoid stdlib package names and the `root`/`env` qualifiers).","Match on SourceRootError::ReservedDependencyName and surface a clear message telling the user which name is reserved and why.","Pre-validate dependency names in your tool against the reserved set before calling add_dependency.","If the intent is to use the stdlib package, drop the explicit dependency — it is already implicit."],"exampleFix":"// before\ndb.add_dependency(root, name!(\"env\"), &dep_root).unwrap();\n// after\nlet alias = name!(\"project_env\"); // any non-reserved name\ndb.add_dependency(root, alias, &dep_root)?;","handlingStrategy":"validation","validationCode":"const RESERVED: &[&str] = &[\"root\", \"env\", /* stdlib package names */];\nif RESERVED.contains(&dep_name.as_str()) {\n    return Err(format!(\"dependency name `{dep_name}` is reserved\"));\n}","typeGuard":null,"tryCatchPattern":"match db.add_dependency(root, dep_name, &dep_root) {\n    Err(SourceRootError::ReservedDependencyName { name }) => {\n        eprintln!(\"`{name}` is reserved (stdlib or source qualifier); choose another name\");\n    }\n    other => other?,\n}","preventionTips":["Maintain a list of reserved names (stdlib packages plus `root` and `env`) and validate dependency names against it at config-parse time.","Avoid naming local packages after stdlib packages.","Surface reserved-name errors to users early in your tooling rather than at database construction."],"tags":["rust","database","naming","reserved-identifier","validation"],"backgroundTag":"invalid-identifier","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}