gchq/CyberChef · error · OperationError
Unknown input format '${inFormat}'
Error message
Unknown input format '${inFormat}' What it means
Thrown by convertCoordinates in the default case of its inFormat switch: the supplied inFormat string did not match any known format case ('Geohash', 'Military Grid Reference System', 'Ordnance Survey National Grid', 'Universal Transverse Mercator', 'Degrees Minutes Seconds', 'Degrees Decimal Minutes', 'Decimal Degrees'). Note the message uses a template literal but the thrown string still contains the literal '${inFormat}' substring only if interpolation is absent — here it interpolates the actual value.
Source
Thrown at src/core/lib/ConvertCoordinates.mjs:213
case "Decimal Degrees":
if (isPair) {
splitLat = splitInput(split[0]);
splitLong = splitInput(split[1]);
if (splitLat.length !== 1 || splitLong.length !== 1) {
throw new OperationError("Invalid co-ordinate format for Decimal Degrees.");
}
latlon = new LatLonEllipsoidal(splitLat[0], splitLong[0]);
} else {
// Not a pair, so only try to convert one set of co-ordinates
splitLat = splitInput(split[0]);
if (splitLat.length !== 1) {
throw new OperationError("Invalid co-ordinate format for Decimal Degrees.");
}
latlon = new LatLonEllipsoidal(splitLat[0], splitLat[0]);
}
break;
default:
throw new OperationError(`Unknown input format '${inFormat}'`);
}
// Everything is now a geodesy latlon object
// These store the latitude and longitude as decimal
if (inFormat.includes("Degrees")) {
// If the input string contains directions, we need to check if they're S or W.
// If either of the directions are, we should make the decimal value negative
const dirs = input.toUpperCase().match(/[NESW]/g);
if (dirs && dirs.length >= 1) {
// Make positive lat/lon values with S/W directions into negative values
if (dirs[0] === "S" || dirs[0] === "W" && latlon.lat > 0) {
latlon.lat = -latlon.lat;
}
if (dirs.length >= 2) {
if (dirs[1] === "S" || dirs[1] === "W" && latlon.lon > 0) {
latlon.lon = -latlon.lon;
}
}View on GitHub (pinned to 4290ea7539)
Solutions
- Use one of the exact canonical format names from the FORMATS export.
- If accepting user input, validate against FORMATS.includes(inFormat) before calling.
- Default to 'Auto' detection when the format is uncertain.
Example fix
// before
convertCoordinates(coords, "DMS", ...); // not a recognised case -> throws
// after
import { FORMATS } from "...ConvertCoordinates.mjs";
convertCoordinates(coords, "Degrees Minutes Seconds", ...); Defensive patterns
Strategy: type-guard
Validate before calling
import { FORMATS } from ".../ConvertCoordinates.mjs";
if (!FORMATS.includes(inFormat)) {
throw new Error(`Unknown inFormat '${inFormat}'. Valid: ${FORMATS.join(", ")}`);
} Type guard
function isKnownFormat(f) {
const FORMATS = ["Degrees Minutes Seconds","Degrees Decimal Minutes","Decimal Degrees","Geohash","Military Grid Reference System","Ordnance Survey National Grid","Universal Transverse Mercator"];
return typeof f === "string" && FORMATS.includes(f);
} Prevention
- Always source inFormat from the FORMATS export, never hand-typed strings.
- Validate user-supplied format strings against FORMATS before calling.
- Default to 'Auto' when format is uncertain.
When it happens
Trigger: convertCoordinates called with an inFormat that is misspelled, abbreviated, in a different case, or not in the FORMATS list — e.g. 'DMS', 'decdeg', 'GeohAsh', null, or undefined.
Common situations: Hardcoding a format string that drifts from the canonical names; passing a user-typed format without validation; case sensitivity mismatches; passing undefined when inFormat is not supplied.
Related errors
- Error converting co-ordinates.
- Unable to detect the input delimiter automatically.
- Unable to detect the input format automatically.
- Invalid co-ordinate format for Degrees Minutes Seconds
- Invalid co-ordinate format for Degrees Decimal Minutes.
AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13).
Data as JSON: /api/errors/46e87a94b32199a6.
Report an issue: GitHub.