{"record":{"id":"2b84c90d5e7670d7","repo":"perspective-dev/perspective","slug":"tilesourcespec-must-be-an-object","errorCode":null,"errorMessage":"TileSourceSpec must be an object","messagePattern":"TileSourceSpec must be an object","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/viewer-charts/src/ts/map/tile-source.ts","lineNumber":131,"sourceCode":"\n    /** See {@link TileSource.attribution}. */\n    readonly attribution: string;\n\n    /** See {@link TileSource.tileSize}. Default 256. */\n    readonly tile_size: number;\n\n    /** See {@link TileSource.maxZoom}. Default 19. */\n    readonly max_zoom: number;\n}\n\n/**\n * Validate + normalize an untrusted spec (a JSON entry or a\n * `registerTileSource` argument). Throws `TypeError` naming the\n * offending field; returns a frozen spec with defaults applied.\n */\nexport function parseTileSourceSpec(input: unknown): TileSourceSpec {\n    if (typeof input !== \"object\" || input === null) {\n        throw new TypeError(\"TileSourceSpec must be an object\");\n    }\n\n    const raw = input as Record<string, unknown>;\n    const str = (key: string): string => {\n        const v = raw[key];\n        if (typeof v !== \"string\" || v.length === 0) {\n            throw new TypeError(\n                `TileSourceSpec.${key} must be a non-empty string`,\n            );\n        }\n\n        return v;\n    };\n\n    const id = str(\"id\");\n    const label = str(\"label\");\n    const template = str(\"template\");\n    const attribution = str(\"attribution\");","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/perspective-dev/perspective/blob/11c8238c0c9c0b9e490b5a6a2dc277afad1e980a/packages/viewer-charts/src/ts/map/tile-source.ts#L113-L149","documentation":"parseTileSourceSpec is a validation/normalization gate for untrusted tile source input (JSON entries or registerTileSource arguments). This generic guard fires when the input is not a non-null object — e.g. a raw string, number, array element misplaced, or null — so field validation cannot proceed. A TypeError naming the offending spec is expected behavior of this validator.","triggerScenarios":"Thrown at packages/viewer-charts/src/ts/map/tile-source.ts:131 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass an object with id/label/template/attribution fields instead of a scalar or null","Check JSON parsing: the value may have been double-unwrapped or defaulted to null","Wrap registerTileSource calls in try/catch to surface the misconfigured spec to the caller"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"11c8238c0c9c0b9e490b5a6a2dc277afad1e980a","analyzedAt":"2026-09-09T00:35:19.377Z","contentChangedAt":"2026-09-09T00:35:19.377Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}