laurent22/joplin · error · Error

${errorPrefix}: values for ${key} must be pairs of strings

Error message

${errorPrefix}: values for ${key} must be pairs of strings

What it means

Thrown inside `getReplacements` when an entry is an array but at least one of its two elements is not a string. Both the pattern and the replacement must be strings.

Source

Thrown at packages/app-mobile/services/voiceTyping/whisper.ts:53

		};
		const processOutputSettings = () => {
			if (!('output' in json)) return;
			if (typeof json.output !== 'object') {
				throw new Error(`${errorPrefix}: Field "output" is not an object`);
			}

			const getReplacements = (key: string, value: unknown) => {
				if (!Array.isArray(value)) {
					throw new Error(`${errorPrefix}: ${key} must be an array`);
				}

				const results: [string, string][] = [];
				for (const replacement of value) {
					if (!Array.isArray(replacement)) {
						throw new Error(`${errorPrefix}: values for ${key} must be arrays`);
					}
					if (typeof replacement[0] !== 'string' || typeof replacement[1] !== 'string') {
						throw new Error(`${errorPrefix}: values for ${key} must be pairs of strings`);
					}

					results.push([replacement[0], replacement[1]]);
				}
				return results;
			};

			if ('stringReplacements' in json.output) {
				this.stringReplacements = getReplacements('stringReplacements', json.output.stringReplacements);
			}

			if ('regexReplacements' in json.output) {
				this.regexReplacements = getReplacements('regexReplacements', json.output.regexReplacements).map(([key, value]) => {
					return [new RegExp(key, 'g'), value];
				});
			}
		};

View on GitHub (pinned to 2654b33620)

Solutions

  1. Ensure both elements of each pair are strings (regex patterns as string sources).
  2. Re-download the model bundle.
  3. Schema-validate pairs as `[string, string]`.

Example fix

// before
"regexReplacements": [[ /^foo/, "bar"]]

// after
"regexReplacements": [[ "^foo", "bar"]]
Defensive patterns

Strategy: type-guard

Validate before calling

for (const entry of config.output.stringReplacements ?? []) {
  if (!Array.isArray(entry) || typeof entry[0] !== 'string' || typeof entry[1] !== 'string') {
    throw new Error('Whisper config: replacement pair must be [string, string]');
  }
}

Type guard

const isStringPair = (v: unknown): v is [string, string] =>
  Array.isArray(v) && v.length >= 2 &&
  typeof v[0] === 'string' && typeof v[1] === 'string';

Try / catch

null

Prevention

When it happens

Trigger: Config like `{ "stringReplacements": [[ 1, "b" ]] }` or a regex entry where the pattern is not a string (regexes must be supplied as string source then compiled by the config loader).

Common situations: Authoring error using a number or object instead of a string; for `regexReplacements`, passing an actual `RegExp` literal serialized incorrectly.

Related errors


AI-assisted analysis of laurent22/joplin@2654b33620 (2026-08-12). Data as JSON: /api/errors/41d194cb633b35b0. Report an issue: GitHub.