koala73/worldmonitor · warning · ApiError
Invalid region: only global is supported
Error message
Invalid region: only global is supported
What it means
getTemporalBaseline only serves the 'global' temporal baseline dataset. The handler normalizes a missing region to 'global' and rejects any explicitly provided other value with a 400 ApiError, because no per-region baseline data is produced or seeded.
Solutions
- Remove the region field from the request (or set it to 'global') and filter client-side instead.
- Update callers so region-scoped logic goes through the region-aware endpoints rather than getTemporalBaseline.
- If per-region baselines are genuinely needed, extend the backend seeding to produce regional baselines before passing region here.
Example fix
// before
await client.getTemporalBaseline({ region: selectedCountry });
// after
await client.getTemporalBaseline({ region: 'global' }); // or omit region
const scoped = baseline.events.filter((e) => e.countryCode === selectedCountry); Defensive patterns
Strategy: validation
Validate before calling
if (typeof region === 'string' && region !== 'global') throw new Error('getTemporalBaseline supports only region "global"; omit the field or use "global".'); Try / catch
try {
const baseline = await client.getTemporalBaseline({ region: 'global' });
} catch (e) {
if (e.status === 400 && /only global is supported/.test(e.message)) {
// stop sending region to this endpoint; filter client-side
}
} Prevention
- Omit the region field for baseline requests instead of forwarding UI filters.
- Keep a shared request-builder per endpoint so region-scoped params only go to region-aware endpoints.
- Document in the client wrapper that baseline is global-only.
When it happens
Trigger: Calling getTemporalBaseline (or its v1 HTTP endpoint) with req.region set to anything other than 'global' — e.g. 'us', 'europe', 'emea', or a country code. Omitting region is fine (defaults to 'global').
Common situations: A client that also calls region-scoped endpoints (coverage, energy profile) reuses the same region field for the baseline request; UI country filters forwarded blindly to all endpoints; proto clients filling the region field with a default like 'us-east-1'.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Invalid scorecard bloc selection.
- Expected an array of Sentry issues. A Sentry error body is a
- Sentry issues response was not an array
- Redis transaction failed: ${results?.error || 'invalid respo
- Unsupported arXiv category
AI-assisted analysis of koala73/worldmonitor@7d06c8633d (2026-09-15).
Data as JSON: /api/errors/d97ddc734591801d.
Report an issue: GitHub.
Appendix: source
Thrown at server/worldmonitor/infrastructure/v1/get-temporal-baseline.ts:27
import {
VALID_BASELINE_TYPES,
MIN_SAMPLES,
Z_THRESHOLD_LOW,
makeBaselineKey,
getBaselineSeverity,
type BaselineEntry,
} from './_shared';
// ========================================================================
// RPC implementation
// ========================================================================
export async function getTemporalBaseline(
_ctx: ServerContext,
req: GetTemporalBaselineRequest,
): Promise<GetTemporalBaselineResponse> {
const region = req.region || 'global';
if (region !== 'global') throw new ApiError(400, 'Invalid region: only global is supported', '');
try {
const { type, count } = req;
if (!type || !VALID_BASELINE_TYPES.includes(type) || typeof count !== 'number' || Number.isNaN(count)) {
return {
learning: false,
sampleCount: 0,
samplesNeeded: 0,
error: 'Missing or invalid params: type and count required',
};
}
const now = new Date();
const weekday = now.getUTCDay();
const month = now.getUTCMonth() + 1;
const key = makeBaselineKey(type, region, weekday, month);
View on GitHub (pinned to 7d06c8633d)