{"record":{"id":"dffe1d3a9e705e86","repo":"lingochamp/FileDownloader","slug":"name-is-empty","errorCode":null,"errorMessage":"name is empty","messagePattern":"name is empty","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"library/src/main/java/com/liulishuo/filedownloader/model/FileDownloadHeader.java","lineNumber":42,"sourceCode":"import java.util.List;\n\n/**\n * We have already handled Etag internal for guaranteeing tasks resuming from the breakpoint, in\n * other words, if the task has downloaded and got Etag, we will add the 'If-Match' and the 'Range'\n * K-V to its request header automatically.\n */\npublic class FileDownloadHeader implements Parcelable {\n\n    private HashMap<String, List<String>> mHeaderMap;\n\n    /**\n     * We have already handled etag, and will add 'If-Match' & 'Range' value if it works.\n     *\n     * @see com.liulishuo.filedownloader.download.ConnectTask#addUserRequiredHeader\n     */\n    public void add(String name, String value) {\n        if (name == null) throw new NullPointerException(\"name == null\");\n        if (name.isEmpty()) throw new IllegalArgumentException(\"name is empty\");\n        if (value == null) throw new NullPointerException(\"value == null\");\n\n        if (mHeaderMap == null) {\n            mHeaderMap = new HashMap<>();\n        }\n\n        List<String> values = mHeaderMap.get(name);\n        if (values == null) {\n            values = new ArrayList<>();\n            mHeaderMap.put(name, values);\n        }\n\n        if (!values.contains(value)) {\n            values.add(value);\n        }\n    }\n\n    /**","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/lingochamp/FileDownloader/blob/6237a8cac174bcc916e4342b14ab1ab72a5768d4/library/src/main/java/com/liulishuo/filedownloader/model/FileDownloadHeader.java#L24-L60","documentation":"A precondition check inside FileDownloadHeader.add: an empty (zero-length) header name is not a valid HTTP header key, so add(name, value) rejects it. The faulty input is a non-null but empty 'name' string.","triggerScenarios":"Thrown at library/src/main/java/com/liulishuo/filedownloader/model/FileDownloadHeader.java:42 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Supply a real header name such as \"Accept\" or \"Range\" instead of an empty string","Trim and validate that the header name is non-empty before calling add","Check where the header map is built for logic that produces \"\" keys (e.g. string concatenation or config parsing bugs)"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6237a8cac174bcc916e4342b14ab1ab72a5768d4","analyzedAt":"2026-09-08T23:50:48.168Z","contentChangedAt":"2026-09-08T23:50:48.168Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}