{"record":{"id":"78460e177bbbdfca","repo":"OpenAPITools/openapi-generator","slug":"negation-with-no-negated-pattern","errorCode":null,"errorMessage":"Negation with no negated pattern.","messagePattern":"Negation with no negated pattern\\.","errorType":"exception","errorClass":"ParserException","httpStatus":null,"severity":"error","filePath":"modules/openapi-generator/src/main/java/org/openapitools/codegen/ignore/rules/IgnoreLineParser.java","lineNumber":69,"sourceCode":"        StringBuilder sb = new StringBuilder();\n        String current = null;\n        String next = null;\n\n        char[] characters = text.toCharArray();\n        for (int i = 0, totalLength = characters.length; i < totalLength; i++) {\n            char character = characters[i];\n            current = String.valueOf(character);\n            next = i < totalLength - 1 ? String.valueOf(characters[i + 1]) : null;\n\n            if (i == 0) {\n                if (\"#\".equals(current)) {\n                    //: A line starting with # serves as a comment.\n                    parts.add(new Part(Token.COMMENT, text));\n                    i = totalLength; // rather than early return\n                    continue;\n                } else if (\"!\".equals(current)) {\n                    if (i == totalLength - 1) {\n                        throw new ParserException(\"Negation with no negated pattern.\");\n                    } else {\n                        parts.add(new Part(Token.NEGATE));\n                        continue;\n                    }\n                } else if (\"\\\\\".equals(current) && \"#\".equals(next)) {\n                    //: Put a backslash (\"`\\`\") in front of the first hash for patterns\n                    //: that begin with a hash.\n                    // NOTE: Just push forward and drop the escape character. Falls through to TEXT token.\n                    current = next;\n                    next = null;\n                    i++;\n                }\n            }\n\n            if (Token.MATCH_ANY.pattern.equals(current)) {\n\n                if (Token.MATCH_ANY.pattern.equals(next)) {\n                    // peek ahead for invalid pattern. Slightly inefficient, but acceptable.","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/ignore/rules/IgnoreLineParser.java#L51-L87","documentation":"IgnoreLineParser throws ParserException when a line in .openapi-generator-ignore consists of exactly '!' with nothing after it. '!' negates the pattern that follows; with no negated pattern the gitignore-style rule cannot be built, so parsing fails fast.","triggerScenarios":"The .openapi-generator-ignore file in the output directory contains a line whose only character is '!' (the parser checks i == totalLength - 1 at position 0). Parsing of the ignore file aborts and generation stops.","commonSituations":"Hand-editing the ignore file and leaving a stray '!'; git merge-conflict leftovers; misunderstanding the syntax by assuming a lone '!' flips the default ignore behavior.","solutions":["Delete the bare '!' line from .openapi-generator-ignore.","Complete the negation if one was intended, e.g. '!/docs/README.md' to re-include a file ignored by a broader pattern.","Scan the file for merge-conflict markers or truncated edits that left the line incomplete."],"exampleFix":"# .openapi-generator-ignore (before):\n!\n/docs/**\n# after:\n/docs/**\n!/docs/README.md","handlingStrategy":"validation","validationCode":"// Pre-flight: lint .openapi-generator-ignore before generation\nimport java.nio.file.*;\n\nfor (String line : Files.readAllLines(Paths.get(outputDir, \".openapi-generator-ignore\"))) {\n    if (line.trim().equals(\"!\"))\n        throw new IllegalStateException(\"Invalid ignore line '!' — negation with no pattern\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat every '!' in .openapi-generator-ignore as incomplete until followed by a pattern.","Add the ignore file to lint/pre-commit checks in repos that regenerate code.","Resolve git merge conflicts in .openapi-generator-ignore completely; leftover fragments often produce bare '!' lines."],"tags":["ignore-file","parser","negation","openapi-generator-ignore"],"backgroundTag":"invalid-ignore-pattern","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}