{"record":{"id":"c134613cc55cf03d","repo":"bazelbuild/bazel","slug":"name-s-is-not-defined","errorCode":null,"errorMessage":"name '%s' is not defined","messagePattern":"name '(.+?)' is not defined","errorType":"exception","errorClass":"Undefined","httpStatus":null,"severity":"error","filePath":"src/main/java/net/starlark/java/eval/Module.java","lineNumber":294,"sourceCode":"    }\n\n    // universal?\n    if (Starlark.UNIVERSE.containsKey(name)) {\n      return Resolver.Scope.UNIVERSAL;\n    }\n    if (resolveTypeSyntax && Starlark.UNIVERSE_EXTRA_TYPE_CONSTRUCTORS.containsKey(name)) {\n      return Resolver.Scope.UNIVERSAL;\n    }\n\n    // undefined\n    Set<String> candidates = new HashSet<>();\n    candidates.addAll(globalIndex.keySet());\n    candidates.addAll(predeclared.keySet());\n    candidates.addAll(Starlark.UNIVERSE.keySet());\n    if (resolveTypeSyntax) {\n      candidates.addAll(Starlark.UNIVERSE_EXTRA_TYPE_CONSTRUCTORS.keySet());\n    }\n    throw new Undefined(String.format(\"name '%s' is not defined\", name), candidates);\n  }\n\n  @Override\n  @Nullable\n  public TypeConstructor getTypeConstructor(String name) throws Undefined {\n    Resolver.Scope scope = resolve(name, /* resolveTypeSyntax= */ true);\n    Object value;\n    switch (scope) {\n      case GLOBAL -> value = getGlobal(name);\n      case PREDECLARED -> value = getPredeclared(name);\n      case UNIVERSAL -> {\n        value = Starlark.UNIVERSE.get(name);\n        if (value == null) {\n          value = Starlark.UNIVERSE_EXTRA_TYPE_CONSTRUCTORS.get(name);\n        }\n      }\n      default -> throw new AssertionError(String.format(\"Unexpected scope: %s\", scope));\n    }","sourceCodeStart":276,"sourceCodeEnd":312,"githubUrl":"https://github.com/bazelbuild/bazel/blob/e6e199d0601a244511b4cf18c8b2828aa73db1fd/src/main/java/net/starlark/java/eval/Module.java#L276-L312","documentation":"The resolver's undefined-name error: a free identifier matched no global binding, no predeclared binding, and no universal (Starlark builtin) name. Module.resolve collects all in-scope names as candidates so the resolver can suggest 'did you mean' alternatives. Thrown as Undefined, typically reported as a load/analysis-time error before execution.","triggerScenarios":"Typos (flase for False), referencing a name defined only inside an if/function that never ran, forgetting load() for a .bzl symbol, using a Python name that Starlark does not provide (e.g. self at module level, or filter/map as builtins depending on semantics).","commonSituations":"Renaming a symbol in one place but not its uses; deleting a rule/function still referenced elsewhere; missing load() statement after splitting a .bzl file; assuming Python builtins (like isinstance in old dialects, or dict) exist in the host application's predeclared environment.","solutions":["Check the exact spelling and case (Starlark builtins are lowercase: len, str, range; constants are None/True/False).","Add the missing load(\"//pkg:file.bzl\", \"symbol\") statement.","Use the error's candidate list / 'did you mean' suggestion to find the intended name.","Ensure the defining statement actually executes before the use (top-level defs and assignments run in order)."],"exampleFix":"# before\nx = flase\n\n# after\nx = False","handlingStrategy":"validation","validationCode":"# ensure the symbol exists before use when availability is uncertain\nif not hasattr(module_ns, \"new_api\"):\n    fail(\"new_api unavailable; update the providing .bzl and its load()\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Read the 'did you mean' candidates in the error to catch typos fast.","Keep load() statements at the top of .bzl files in sync with renames (buildifier can help).","Remember Starlark top-level statements run in order: define before use."],"tags":["starlark","resolution","undefined-name","typo","load"],"backgroundTag":null,"analyzedSha":"e6e199d0601a244511b4cf18c8b2828aa73db1fd","analyzedAt":"2026-08-14T10:24:27.848Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}