ajaxorg/ace · error · Error

Unknown config key:

Error message

Unknown config key: 

What it means

config.get(key) only accepts keys that exist in the options registry (the Ace.ConfigOptions type). Unknown keys are rejected rather than returning undefined, so typos or renamed options fail fast.

Source

Thrown at src/config.js:31

    workerPath: null,
    modePath: null,
    themePath: null,
    basePath: "",
    suffix: ".js",
    $moduleUrls: {},
    loadWorkerFromBlob: true,
    sharedPopups: false,
    useStrictCSP: null
};

/**
 * @template {keyof import("../ace-internal").Ace.ConfigOptions} K
 * @param {K} key - The key of the config option to retrieve.
 * @returns {import("../ace-internal").Ace.ConfigOptions[K]} - The value of the config option.
 */
exports.get = function(key) {
    if (!options.hasOwnProperty(key))
        throw new Error("Unknown config key: " + key);
    return options[key];
};

/**
 * @template {keyof import("../ace-internal").Ace.ConfigOptions} K
 * @param {K} key
 * @param {import("../ace-internal").Ace.ConfigOptions[K]} value
 */
exports.set = function(key, value) {
    if (options.hasOwnProperty(key))
        options[key] = value;
    else if (this.setDefaultValue("", key, value) == false)
        throw new Error("Unknown config key: " + key);
    if (key == "useStrictCSP")
        dom.useStrictCSP(value);
};
/**
 * @return {import("../ace-internal").Ace.ConfigOptions}

View on GitHub (pinned to 2c1eddc392)

Solutions

  1. Check the option name against Ace's documented ConfigOptions list
  2. Use the correct casing/spelling (Ace options are camelCase, e.g. fontSize, useWorker)
  3. Verify loaded Ace version supports the option
  4. Wrap with a hasOwnProperty check on ace.config.getDefaults() keys before calling get

Example fix

// before
const size = ace.config.get('font_size');
// after
const size = ace.config.get('fontSize');
Defensive patterns

Strategy: validation

Validate before calling

var validKeys = Object.keys(ace.config.getDefaults());
if (!validKeys.includes('fontSize')) throw new Error('unsupported option');
var v = ace.config.get('fontSize');

Type guard

function isConfigKey(k) { return typeof k === 'string' && Object.prototype.hasOwnProperty.call(ace.config.getDefaults(), k); }

Try / catch

try { return ace.config.get(key); } catch (e) { if (/Unknown config key/.test(e.message)) return undefined; throw e; }

Prevention

When it happens

Trigger: Calling ace.config.get('theme') (misspelled or legacy option name), or getting an option introduced in a newer/older Ace version than the one loaded.

Common situations: Upgrading Ace and an option was renamed; copying option names from third-party docs; camelCase vs different casing mistakes (e.g. 'font_size' vs 'fontSize').

Related errors


AI-assisted analysis of ajaxorg/ace@2c1eddc392 (2026-08-30). Data as JSON: /api/errors/0dcea2cc7b817e7c. Report an issue: GitHub.