denoland/deno · error

Invalid registry configuration. Url

Error message

Invalid registry configuration. Url "{}" (for variable "{}" in registry with schema "{}") uses variable "{}", which is not allowed because the schema defines "{}" to the right of "{}".

What it means

Registry URL templates in a Deno LSP autocomplete registry configuration may only substitute variables that the schema defines to the LEFT of the variable being resolved. The LSP matches import URLs against the schema left-to-right, so a later variable's value is not yet known when an earlier variable's endpoint is fetched; a forward reference is therefore rejected for both version 1 and 2 configs. The error names the offending URL, the variable being resolved, the schema, and which key is defined too far right.

Solutions

  1. Make the earlier variable's URL self-contained: point it at an endpoint that does not need later variables (e.g. a static module list) so the forward reference disappears.
  2. Restructure the schema string so variables that other URLs depend on appear first, and update it to match the import URLs it should capture.
  3. Have the listing endpoint accept only the information available at that stage (serve it from a proxy that fills in the missing piece server-side).

Example fix

// before (registries.json)
{
  "version": 2,
  "registries": [
    {
      "schema": ":module@:version",
      "variables": [
        { "key": "module", "url": "https://api.example.com/modules?for=${version}" },
        { "key": "version", "url": "https://api.example.com/modules/${module}/versions" }
      ]
    }
  ]
}

// after
{
  "version": 2,
  "registries": [
    {
      "schema": ":module@:version",
      "variables": [
        { "key": "module", "url": "https://api.example.com/modules" },
        { "key": "version", "url": "https://api.example.com/modules/${module}/versions" }
      ]
    }
  ]
}
Defensive patterns

Strategy: validation

Validate before calling

// Reject forward references before the LSP does: a variable's URL may only
// use variables the schema defines to its LEFT (or itself, in version 2).
export function assertNoForwardReferences(config) {
  for (const registry of config.registries ?? []) {
    const keys = [...registry.schema.matchAll(/:([A-Za-z0-9_]+)/g)].map((m) => m[1]);
    for (const v of registry.variables ?? []) {
      const idx = keys.indexOf(v.key);
      const refs = [...v.url.matchAll(/\$\{([A-Za-z0-9_]+)\}/g)].map((m) => m[1]);
      for (const ref of refs) {
        const refIdx = keys.indexOf(ref);
        if (refIdx === -1 || (refIdx > idx && ref !== v.key)) {
          throw new Error(`url for '${v.key}' uses '${ref}', which the schema '${registry.schema}' defines to its right (or not at all)`);
        }
      }
    }
  }
}

Prevention

When it happens

Trigger: Any registry (v1 or v2) where a variable's "url" substitutes a key positioned after it in the schema — e.g. schema ":module@:version" with {"key": "module", "url": "https://example.com/list?version=${version}"}. Also fired when the URL references a name that is not a schema key at all (it is neither left of the variable nor the variable itself).

Common situations: Wrapping an API that needs a later path segment to list earlier ones (listing a module's versions when the schema puts module first); adapting npm-style or Go-module-proxy-style APIs to the Deno registry schema; editing a schema and forgetting the left-to-right ordering rule.

Related errors


AI-assisted analysis of denoland/deno@f7822238ca (2026-08-20). Data as JSON: /api/errors/d291dbc966b5d7c5. Report an issue: GitHub.

Appendix: source

Thrown at cli/lsp/registries.rs:370

      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))?;

      let replacement_variables = parse_replacement_variables(&variable.url);
      let limited_keys = key_names.get(0..key_index).unwrap();
      for v in replacement_variables {
        if variable.key == v && config.version == 1 {
          return Err(anyhow!(
            "Invalid registry configuration. Url \"{}\" (for variable \"{}\" in registry with schema \"{}\") uses variable \"{}\", which is not allowed because that would be a self reference.",
            variable.url,
            variable.key,
            registry.schema,
            v
          ));
        }

        let key_index = limited_keys.iter().position(|key| key == &v);

        if key_index.is_none() && variable.key != v {
          return Err(anyhow!(
            "Invalid registry configuration. Url \"{}\" (for variable \"{}\" in registry with schema \"{}\") uses variable \"{}\", which is not allowed because the schema defines \"{}\" to the right of \"{}\".",
            variable.url,
            variable.key,
            registry.schema,
            v,
            v,
            variable.key
          ));
        }
      }
    }
  }

  Ok(())
}

#[derive(Debug, Clone, Deserialize)]
pub struct RegistryConfigurationVariable {

View on GitHub (pinned to f7822238ca)