{"record":{"id":"7880deb70a72fe7f","repo":"denoland/deno","slug":"invalid-registry-configuration-url-for-vari","errorCode":null,"errorMessage":"Invalid registry configuration. Url \"{}\" (for variable \"{}\" in registry with schema \"{}\") uses variable \"{}\", which is not allowed because that would be a self reference.","messagePattern":"Invalid registry configuration\\. Url \"(.+?)\" \\(for variable \"(.+?)\" in registry with schema \"(.+?)\"\\) uses variable \"(.+?)\", which is not allowed because that would be a self reference\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/lsp/registries.rs","lineNumber":358,"sourceCode":"        .any(|x| x == *key_name)\n      {\n        return Err(anyhow!(\n          \"Invalid registry configuration. Registry with schema \\\"{}\\\" is missing variable declaration for key \\\"{}\\\".\",\n          registry.schema,\n          key_name\n        ));\n      }\n    }\n\n    for variable in &registry.variables {\n      let key_index = key_names.iter().position(|key| *key == variable.key);\n      let key_index = key_index.ok_or_else(||anyhow!(\"Invalid registry configuration. Registry with schema \\\"{}\\\" is missing a path parameter in schema for variable \\\"{}\\\".\", registry.schema, variable.key))?;\n\n      let replacement_variables = parse_replacement_variables(&variable.url);\n      let limited_keys = key_names.get(0..key_index).unwrap();\n      for v in replacement_variables {\n        if variable.key == v && config.version == 1 {\n          return Err(anyhow!(\n            \"Invalid registry configuration. Url \\\"{}\\\" (for variable \\\"{}\\\" in registry with schema \\\"{}\\\") uses variable \\\"{}\\\", which is not allowed because that would be a self reference.\",\n            variable.url,\n            variable.key,\n            registry.schema,\n            v\n          ));\n        }\n\n        let key_index = limited_keys.iter().position(|key| key == &v);\n\n        if key_index.is_none() && variable.key != v {\n          return Err(anyhow!(\n            \"Invalid registry configuration. Url \\\"{}\\\" (for variable \\\"{}\\\" in registry with schema \\\"{}\\\") uses variable \\\"{}\\\", which is not allowed because the schema defines \\\"{}\\\" to the right of \\\"{}\\\".\",\n            variable.url,\n            variable.key,\n            registry.schema,\n            v,\n            v,","sourceCodeStart":340,"sourceCodeEnd":376,"githubUrl":"https://github.com/denoland/deno/blob/f7822238cab635a3a19f99f493f675fa81a7f9d8/cli/lsp/registries.rs#L340-L376","documentation":"Thrown by the Deno language server while validating a third-party autocomplete registry configuration (the JSON the LSP fetches for a completion host configured under deno.suggest.imports.hosts). In a \"version\": 1 configuration, each variable's \"url\" template may only substitute variables the schema defines to its left; a URL that substitutes the variable's own key is rejected as a self reference because v1 resolution has no value for the key being looked up. The check at cli/lsp/registries.rs:348 only applies when config.version == 1, so version 2 configs are allowed to self-reference.","triggerScenarios":"A registry configuration declares \"version\": 1 and contains a variable whose \"url\" embeds a placeholder equal to the variable's own \"key\", e.g. schema \":module\" with {\"key\": \"module\", \"url\": \"https://example.com/modules/${module}\"}. Validation runs when the LSP fetches and parses the registry config (startup or first completion request) and fails the whole config load.","commonSituations":"Authoring a custom completion registry for the Deno VS Code extension; copying a version 2 registry file (which permits self references) into a config that still declares version 1; migrating the old deno.land/x registry format by hand and forgetting to bump the version field.","solutions":["Set \"version\": 2 in the registry configuration JSON — version 2 explicitly permits a variable URL to reference its own key.","Remove the self reference: make the variable's \"url\" a concrete endpoint with no ${...} placeholder for its own key, e.g. \"https://example.com/modules\" for key \"module\".","If the endpoint genuinely needs the key's value, restructure the schema so another variable supplies that information earlier in the path."],"exampleFix":"// before (registries.json)\n{\n  \"version\": 1,\n  \"registries\": [\n    {\n      \"schema\": \":module\",\n      \"variables\": [\n        { \"key\": \"module\", \"url\": \"https://example.com/modules/${module}\" }\n      ]\n    }\n  ]\n}\n\n// after\n{\n  \"version\": 2,\n  \"registries\": [\n    {\n      \"schema\": \":module\",\n      \"variables\": [\n        { \"key\": \"module\", \"url\": \"https://example.com/modules/${module}\" }\n      ]\n    }\n  ]\n}","handlingStrategy":"validation","validationCode":"// Validate a registry configuration before pointing the Deno LSP at it\n// (mirrors validate_config in cli/lsp/registries.rs for self references).\nexport function assertNoSelfReferences(config) {\n  if (config.version === 1) {\n    for (const registry of config.registries ?? []) {\n      for (const v of registry.variables ?? []) {\n        if (v.url.includes(`\\$\\{${v.key}\\}`)) {\n          throw new Error(`variable '${v.key}' self-references in '${v.url}' — use version 2 or remove the reference`);\n        }\n      }\n    }\n  }\n}","typeGuard":"// Narrow an unknown payload to a v2 registry config (self references allowed).\nexport function isV2RegistryConfig(c) {\n  return typeof c === 'object' && c !== null && c.version === 2 &&\n    Array.isArray(c.registries) &&\n    c.registries.every((r) =>\n      typeof r?.schema === 'string' && Array.isArray(r?.variables) &&\n      r.variables.every((v) => typeof v?.key === 'string' && typeof v?.url === 'string')\n    );\n}","tryCatchPattern":null,"preventionTips":["Author registry configurations as version 2 — it is the current format and permits self-referencing variable URLs","Keep a CI validation step applying the same rules the LSP enforces: version 1 or 2, every schema key declared as a variable, no forward references, self references only in v2","Watch the Deno Language Server output panel when first loading a new registry — validation errors surface there on startup or first completion"],"tags":["registries","lsp","autocomplete","configuration","validation","url-template"],"backgroundTag":"registry-config-validation","analyzedSha":"f7822238cab635a3a19f99f493f675fa81a7f9d8","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}