{"record":{"id":"078a855da5e3593b","repo":"louis-e/arnis","slug":"empty-nothing-to-parse","errorCode":null,"errorMessage":"empty -- nothing to parse","messagePattern":"empty -- nothing to parse","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"src/gui/js/bbox.js","lineNumber":118,"sourceCode":"            // try JSON\n            var json = JSON.parse(this.data);\n\n            // try GeoJSON\n            var parsed_data = new L.geoJson(json)\n\n        } catch (err) {\n\n            return null;\n\n        }\n\n        this.parse_type = \"geojson\";\n        return parsed_data;\n    };\n\n    FormatSniffer.prototype._is_wkt = function () {\n        if (this.data === \"\") {\n            throw new Error(\"empty -- nothing to parse\");\n        }\n\n        try {\n            var parsed_data = new Wkt.Wkt(this.data);\n        } catch (err) {\n            return null;\n        }\n\n        this.parse_type = \"wkt\";\n        return parsed_data;\n    };\n\n    FormatSniffer.prototype._sniffFormat = function () {\n\n        var parsed_data = null;\n        var fail = false;\n        try {\n            var next = true;","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/louis-e/arnis/blob/34048924d9365795fb0d832e76140a3fbdc413d9/src/gui/js/bbox.js#L100-L136","documentation":"FormatSniffer._is_wkt attempts to parse the sniffed input as WKT. When the input data is the empty string, there is nothing to parse, so the function throws 'empty -- nothing to parse' rather than returning null like other parse failures. Callers must treat empty input as a distinct error case from 'not WKT'.","triggerScenarios":"Calling _is_wkt (or the format-sniffing entry point that dispatches to it) on a FormatSniffer whose data property is \"\" — e.g. sniffing an empty file, an empty textarea, or an empty pasted string.","commonSituations":"User submits a bounding-box/GUI form without entering any data; a file input reads a zero-byte file; upstream code trimmed whitespace-only input down to \"\" before sniffing; automated tests passing empty fixtures.","solutions":["Guard before sniffing: check this.data === \"\" (or trim() === \"\") and return null / a 'no input' result instead of invoking _is_wkt.","Wrap the sniffing call in try/catch and treat the 'empty -- nothing to parse' message as 'no data provided' rather than a parse failure.","Fix the UI layer to disable sniffing/parse until the user supplies non-empty input."],"exampleFix":"// before\nvar format = sniffer._is_wkt(); // throws on empty input\n// after\nif (!sniffer.data || sniffer.data.trim() === \"\") {\n    return null; // nothing to parse\n}\nvar format = sniffer._is_wkt();","handlingStrategy":"validation","validationCode":"if (typeof data !== 'string' || data.trim() === '') {\n    return null; // nothing to sniff\n}","typeGuard":"function isNonEmptyString(v) {\n  return typeof v === 'string' && v.trim().length > 0;\n}","tryCatchPattern":"try {\n  return sniffer._is_wkt();\n} catch (err) {\n  if (err && err.message === 'empty -- nothing to parse') return null;\n  throw err;\n}","preventionTips":["Trim input before sniffing so whitespace-only input is handled as empty","Disable parse/submit controls until the user enters non-empty data","Handle zero-byte files as a distinct 'no input' case before format detection"],"tags":["javascript","parsing","wkt","input-validation"],"backgroundTag":"empty-input-parse-error","analyzedSha":"34048924d9365795fb0d832e76140a3fbdc413d9","analyzedAt":"2026-09-03T14:05:17.283Z","contentChangedAt":"2026-09-03T14:05:17.283Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}