{"record":{"id":"3bc5063d12c92eb0","repo":"perspective-dev/perspective","slug":"tilesourcespec-key-must-be-a-non-empty-string","errorCode":null,"errorMessage":"TileSourceSpec.${key} must be a non-empty string","messagePattern":"TileSourceSpec\\.(.+?) must be a non-empty string","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/viewer-charts/src/ts/map/tile-source.ts","lineNumber":138,"sourceCode":"    /** 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\");\n    for (const placeholder of [\"{z}\", \"{x}\", \"{y}\"]) {\n        if (!template.includes(placeholder)) {\n            throw new TypeError(\n                `TileSourceSpec.template must contain \"${placeholder}\"`,\n            );\n        }\n    }","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/perspective-dev/perspective/blob/11c8238c0c9c0b9e490b5a6a2dc277afad1e980a/packages/viewer-charts/src/ts/map/tile-source.ts#L120-L156","documentation":"Generic string-field guard inside parseTileSourceSpec: the local helper str(key) throws this TypeError whenever a required string field (id, label, template, or attribution) of the tile source spec is missing, not a string, or an empty string. The interpolated key identifies which field failed.","triggerScenarios":"Thrown at packages/viewer-charts/src/ts/map/tile-source.ts:138 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Supply a non-empty string for the field named in the message","Check for undefined fields from incomplete JSON definitions of the tile source","Default-check required fields before calling registerTileSource"],"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"}