{"record":{"id":"d291dbc966b5d7c5","repo":"denoland/deno","slug":"invalid-registry-configuration-url-for-vari-d291db","errorCode":null,"errorMessage":"Invalid registry configuration. Url \"{}\" (for variable \"{}\" in registry with schema \"{}\") uses variable \"{}\", which is not allowed because the schema defines \"{}\" to the right of \"{}\".","messagePattern":"Invalid registry configuration\\. Url \"(.+?)\" \\(for variable \"(.+?)\" in registry with schema \"(.+?)\"\\) uses variable \"(.+?)\", which is not allowed because the schema defines \"(.+?)\" to the right of \"(.+?)\"\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/lsp/registries.rs","lineNumber":361,"sourceCode":"      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,\n            variable.key\n          ));\n        }\n      }\n    }\n  }\n\n  Ok(())\n}\n\n#[derive(Debug, Clone, Deserialize)]\npub struct RegistryConfigurationVariable {","sourceCodeStart":343,"sourceCodeEnd":379,"githubUrl":"https://github.com/denoland/deno/blob/89f33cbef296a2b287f323d42de54c871fa69c77/cli/lsp/registries.rs#L343-L379","documentation":"cli/lsp/registries.rs:361 enforces left-to-right dependency order: a variable's URL may only interpolate variables whose schema placeholders occur strictly to the LEFT of the variable's own placeholder (limited_keys = key_names[..key_index]). Referencing a placeholder defined later in the schema produces this \"defines ... to the right of ...\" error, because completion for the earlier key cannot know the later key's value yet.","triggerScenarios":"Schema \"/x/:version/:package\" with { \"key\": \"version\", \"url\": \"https://example.com/v/${package}\" } — version's URL references package, which sits to its right in the schema.","commonSituations":"Registry schemas reordered for URL aesthetics after the variables were written; multi-segment paths where authors assume any variable can be interpolated anywhere.","solutions":["Reorder the schema so referenced placeholders come first: \"/x/:package/:version\"","Or change the URL to only interpolate placeholders that already appear left of the variable","Validate the ordering with a script before publishing the config (see defense section)"],"exampleFix":"// before\n{ \"schema\": \"/x/:version/:package\", \"variables\": [ { \"key\": \"version\", \"url\": \"https://example.com/p/${package}/v\" } ] }\n\n// after\n{ \"schema\": \"/x/:package/:version\", \"variables\": [ { \"key\": \"version\", \"url\": \"https://example.com/p/${package}/v\" } ] }","handlingStrategy":"validation","validationCode":"const order = [...r.schema.matchAll(/:([A-Za-z0-9_]+)/g)].map(m => m[1]);\nfor (const v of r.variables) {\n  const own = order.indexOf(v.key);\n  for (const ref of v.url.matchAll(/\\$\\{([A-Za-z0-9_]+)\\}/g)) {\n    if (order.indexOf(ref[1]) > own) throw new Error(`${v.key} references ${ref[1]} defined to its right`);\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Design schemas so broad, early segments (owner, package) come before narrow ones (version, path)","Only interpolate variables that appear to the left of the referencing key"],"tags":["lsp","registry","configuration","ordering"],"backgroundTag":null,"analyzedSha":"89f33cbef296a2b287f323d42de54c871fa69c77","analyzedAt":"2026-08-16T07:54:21.310Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}