jackwener/OpenCLI · error · EmptyResultError
${label} could not find location "${location}".
Error message
${label} could not find location "${location}". What it means
This EmptyResultError is thrown when wttr.in answers HTTP 404 for the requested location, meaning wttr.in could not geocode the given location string to any place. It is a client-input problem (unknown location), not a service outage.
Source
Thrown at clis/wttr/utils.js:28
export function requireString(value, name) {
if (typeof value !== 'string' || !value.trim()) {
throw new ArgumentError(`--${name} is required`);
}
return value.trim();
}
export async function wttrFetch(location, label) {
// wttr.in path-encodes the location. Spaces → %20 is fine; commas survive.
const url = `${WTTR_BASE}/${encodeURIComponent(location)}?format=j1`;
let resp;
try {
resp = await fetch(url, { headers: { 'User-Agent': UA, accept: 'application/json' } });
} catch (err) {
throw new CommandExecutionError(`${label} request failed: ${err.message}`);
}
if (resp.status === 404) {
throw new EmptyResultError(label, `${label} could not find location "${location}".`);
}
if (!resp.ok) {
throw new CommandExecutionError(`${label} returned HTTP ${resp.status}.`);
}
let body;
try {
body = await resp.json();
} catch (err) {
// wttr.in falls back to plain-text "Unknown location" for some bad inputs;
// promote that to EmptyResult instead of pretending we got JSON.
throw new EmptyResultError(label, `${label} returned non-JSON body (likely unknown location).`);
}
return body;
}
// wttr.in's "weatherDesc" / "lang_en" fields are arrays of `{ value: '...' }` objects.
// Single-element 99% of the time but the schema is a list.
export function pickWeatherDesc(arr) {View on GitHub (pinned to 49907e53dc)
Solutions
- Use a simpler or canonical location name ('London', airport code 'LHR', or 'lat,lon')
- Verify the location resolves with curl 'https://wttr.in/<loc>?format=j1'
- Catch EmptyResultError and prompt the user to correct the location
Example fix
// before
await query({ location: 'San Fransisco' }); // typo -> 404
// after
await query({ location: 'San Francisco' }); // or '37.77,-122.42' Defensive patterns
Strategy: fallback
Validate before calling
// Verify the location geocodes before calling
const probe = await fetch(`https://wttr.in/${encodeURIComponent(loc)}?format=j1`);
if (probe.status === 404) throw new Error(`Unknown location: ${loc}`); Try / catch
try {
result = await query({ location });
} catch (err) {
if (err instanceof EmptyResultError) {
result = await query({ location: nearestKnownCity });
} else throw err;
} Prevention
- Normalize/trim location input and strip stray characters
- Accept lat,lon pairs for unambiguous geocoding
- Maintain a suggestion list of known-good location formats (city, IATA code, lat,lon)
- Catch EmptyResultError and re-prompt the user instead of crashing
When it happens
Trigger: wttrFetch receives resp.status === 404 from https://wttr.in/<location>?format=j1; any command passing an unresolvable location string hits it.
Common situations: Misspelled city names; passing ZIP codes or region names wttr.in cannot geocode; encoding artifacts (e.g. stray characters) in the location; using place names unique to another geocoder's index.
Related errors
- Chess.com returned 404 for ${url}
- coingecko has no coin with id "${id}".
- crates.io returned 404 for ${url}.
- dblp returned 404 — the requested record may not exist.
- No Lobste.rs stories found for domain "${domain}".
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/6d848f27c24f7207.
Report an issue: GitHub.