denoland/deno · error
Invalid registry configuration. Expected version 1 or 2 got
Error message
Invalid registry configuration. Expected version 1 or 2 got {}. What it means
The Deno LSP downloads a per-origin registry configuration (config.json) describing completion schemas for custom module registries; validate_config in cli/lsp/registries.rs:304 rejects any document whose top-level "version" integer is outside 1..=2. Version defines the semantics of variable references (v1 forbids self-references, v2 allows them), so an unknown major is unsafe to interpret.
Source
Thrown at cli/lsp/registries.rs:304
url: &str,
variable: &Key,
maybe_value: Option<&str>,
) -> String {
let url_str = url.to_string();
let value = maybe_value.unwrap_or("");
if let StringOrNumber::String(name) = &variable.name {
url_str
.replace(&format!("${{{name}}}"), value)
.replace(&format! {"${{{{{name}}}}}"}, value)
} else {
url_str
}
}
/// Validate a registry configuration JSON structure.
fn validate_config(config: &RegistryConfigurationJson) -> Result<(), AnyError> {
if config.version < 1 || config.version > 2 {
return Err(anyhow!(
"Invalid registry configuration. Expected version 1 or 2 got {}.",
config.version
));
}
for registry in &config.registries {
let (_, keys) = string_to_regex(®istry.schema, None)?;
let key_names: Vec<String> = keys
.map(|keys| {
keys
.iter()
.filter_map(|k| {
if let StringOrNumber::String(s) = &k.name {
Some(s.clone())
} else {
None
}
})
.collect()View on GitHub (pinned to 89f33cbef2)
Solutions
- Set "version": 2 (current) in the origin's config.json
- If you maintain a v1-era config, keep "version": 1 and its stricter self-reference rules
- If you don't control the origin, disable that host in the editor's import-completion hosts so the LSP stops fetching it
Example fix
// before (https://example.com/config.json)
{ "version": 3, "registries": [ ... ] }
// after
{ "version": 2, "registries": [ ... ] } Defensive patterns
Strategy: validation
Validate before calling
const cfg = JSON.parse(configJsonText);
if (!Number.isInteger(cfg.version) || cfg.version < 1 || cfg.version > 2) {
throw new Error(`unsupported registry config version: ${cfg.version}`);
} Type guard
function isKnownRegistryConfig(v: unknown): v is { version: 1 | 2; registries: unknown[] } {
const o = v as Record<string, unknown>;
return (o.version === 1 || o.version === 2) && Array.isArray(o.registries);
} Prevention
- Serve config.json from a template tested against the version field enum
- Disable unused completion hosts in the editor so foreign/broken configs are never fetched
- Track Deno release notes when bumping registry config majors
When it happens
Trigger: A registry serving { "version": 3, "registries": [...] } or version 0; the origin's config.json is fetched when the editor first requests completions for that host (enabled via import-suggestion hosts).
Common situations: Registry authors drafting a v3 schema; an origin serving a stub/placeholder config; integers parsed from a YAML-ish hand-edit that dropped the version field to 0 via default.
Related errors
- Invalid registry configuration. Registry with schema "{}" is
- Invalid registry configuration. Registry with schema "{}" is
- Invalid registry configuration. Url "{}" (for variable "{}"
- Invalid registry configuration. Url "{}" (for variable "{}"
- Cannot create cron job, a unique name is required: received
AI-assisted analysis of denoland/deno@89f33cbef2 (2026-08-16).
Data as JSON: /api/errors/a99963bb650e3485.
Report an issue: GitHub.