{"record":{"id":"dd17afa74515e52d","repo":"koala73/worldmonitor","slug":"aircraft-identifier-is-too-long","errorCode":null,"errorMessage":"Aircraft identifier is too long","messagePattern":"Aircraft identifier is too long","errorType":"validation","errorClass":"ApiError","httpStatus":400,"severity":"warning","filePath":"server/worldmonitor/aviation/v1/track-aircraft.ts","lineNumber":118,"sourceCode":"    if (req.icao24) return `aviation:track:icao:${req.icao24}:v2`;\n    if (req.callsign) return `aviation:track:callsign:${req.callsign.toUpperCase()}:v2`;\n    if (!isDegenerateBbox(req)) {\n        return `aviation:track:bbox:${Math.floor(req.swLat)}:${Math.floor(req.swLon)}:${Math.ceil(req.neLat)}:${Math.ceil(req.neLon)}:v1`;\n    }\n    return 'aviation:track:all:v2';\n}\n\n// Response-level source values (TrackAircraftResponse.source):\n//   'opensky'           — data from OpenSky via relay\n//   'wingbits'          — data from Wingbits via relay\n//   'none'              — all real sources returned empty or failed; positions = []\nexport async function trackAircraft(\n    ctx: ServerContext,\n    req: TrackAircraftRequest,\n): Promise<TrackAircraftResponse> {\n    const rawIcao24 = req.icao24 ?? '';\n    const rawCallsign = req.callsign ?? '';\n    if (rawIcao24.length > 16 || rawCallsign.length > 16) throw new ApiError(400, 'Aircraft identifier is too long', '');\n    const icao24 = rawIcao24.trim().toLowerCase();\n    const callsign = rawCallsign.trim().toUpperCase();\n    if (rawIcao24 && !/^[0-9a-f]{6}$/.test(icao24)) throw new ApiError(400, 'Expected a six-character hexadecimal ICAO address', '');\n    if (rawCallsign && !/^[A-Z0-9]{1,8}$/.test(callsign)) throw new ApiError(400, 'Expected an alphanumeric callsign of at most eight characters', '');\n    req = { ...req, icao24, callsign };\n    if (icao24 || callsign) await admitIdentifierLookup(ctx.request);\n\n    const redistributableOnly = requiresRedistributableProviders(ctx.request);\n    const cacheKey = `${buildCacheKey(req)}${redistributableOnly ? ':redistributable' : ''}`;\n\n    let result: { positions: PositionSample[]; source: string } | null = null;\n    try {\n        const positiveTtl = req.callsign ? CALLSIGN_CACHE_TTL : CACHE_TTL;\n        const negativeTtl = req.callsign ? CALLSIGN_NEGATIVE_TTL : CACHE_TTL;\n        result = await cachedFetchJson<{ positions: PositionSample[]; source: string }>(\n            cacheKey, positiveTtl, async () => {\n                const relayBase = getRelayBaseUrl();\n                const isCallsignOnly = !!req.callsign && !req.icao24 && isDegenerateBbox(req);","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/koala73/worldmonitor/blob/7d06c8633d256c18e38133030bc3613976a96ec9/server/worldmonitor/aviation/v1/track-aircraft.ts#L100-L136","documentation":"trackAircraft caps both req.icao24 and req.callsign at 16 raw characters before normalization; anything longer throws ApiError(400, 'Aircraft identifier is too long'). This is a cheap pre-normalization length guard so oversized garbage never reaches providers or rate-limit admission.","triggerScenarios":"Calling track-aircraft with icao24 or callsign strings longer than 16 characters, e.g. pasted full hex dumps, concatenated identifiers, or an unbounded user input field.","commonSituations":"UI search box sending 'icao24=abc123 callsign=UAL123' as one string; logging pipelines passing whole ADS-B messages; test fixtures with placeholder multi-field strings.","solutions":["Limit the identifier input to 16 characters client-side before calling","Send icao24 and callsign as separate fields, never combined","Catch ApiError and surface 'Aircraft identifier is too long' with a hint to shorten input"],"exampleFix":"// before\nawait trackAircraft(ctx, { icao24: '406b7f' , callsign: 'DLH441 LH441 EXTRA' });\n// after\nconst callsign = raw.callsign.slice(0, 8);\nawait trackAircraft(ctx, { icao24: raw.icao24.slice(0, 16), callsign });","handlingStrategy":"validation","validationCode":"if (req.icao24.length > 16 || req.callsign.length > 16) throw new Error('aircraft identifiers must be <= 16 chars');","typeGuard":"const isShortIdentifier = (v: unknown): v is string => typeof v === 'string' && v.length <= 16;","tryCatchPattern":"try {\n  return await trackAircraft(ctx, req);\n} catch (e) {\n  if (e instanceof ApiError && e.status === 400 && /too long/.test(e.message)) {\n    return { error: 'Identifier too long', fix: 'trim to <= 16 chars' };\n  }\n  throw e;\n}","preventionTips":["Slice identifier inputs to 16 characters at the UI layer","Keep icao24 and callsign in separate fields","Sanitize pasted ADS-B text before lookup"],"tags":["validation","input-length","aviation"],"backgroundTag":"value-out-of-range","analyzedSha":"7d06c8633d256c18e38133030bc3613976a96ec9","analyzedAt":"2026-09-15T16:44:39.439Z","contentChangedAt":"2026-09-15T16:44:39.439Z","schemaVersion":2},"datasetVersion":"2026-09-15T18:17:12.389Z"}