{"record":{"id":"caf40772e7c2daa2","repo":"antonmedv/fx","slug":"unexpected-end-of-input-in-comment","errorCode":null,"errorMessage":"Unexpected end of input in comment","messagePattern":"Unexpected end of input in comment","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/jsonx/json.go","lineNumber":614,"sourceCode":"func (p *JsonParser) skipComment() {\n\tp.next()\n\tswitch p.char {\n\tcase '/':\n\t\tfor p.char != '\\n' && p.char != 0 {\n\t\t\tp.next()\n\t\t}\n\tcase '*':\n\t\tfor {\n\t\t\tp.next()\n\t\t\tif p.char == '*' {\n\t\t\t\tp.next()\n\t\t\t\tif p.char == '/' {\n\t\t\t\t\tp.next()\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t\tif p.char == 0 {\n\t\t\t\tpanic(\"Unexpected end of input in comment\")\n\t\t\t}\n\t\t}\n\tdefault:\n\t\tpanic(fmt.Sprintf(\"Invalid comment: '/%c'\", p.char))\n\t}\n}\n","sourceCodeStart":596,"sourceCodeEnd":621,"githubUrl":"https://github.com/antonmedv/fx/blob/4f31cd3a0c5d66f1b4290a2719bab14a5cee8ebe/internal/jsonx/json.go#L596-L621","documentation":"While skipping a /* block comment in lenient mode, the parser scans for the closing */. If it hits EOF (p.char == 0) before finding it, the comment was never terminated, so it panics with 'Unexpected end of input in comment'. This protects against silently swallowing the rest of the document.","triggerScenarios":"Parsing non-strict JSON whose block comment lacks the closing */ — e.g. '{ \"a\": 1 /* oops' or a file truncated mid-comment.","commonSituations":"Manually commented-out sections of config where the closing */ was deleted, copy/paste dropping the last characters, log files truncated mid-write.","solutions":["Close the block comment with */ in the input.","Delete the unterminated /* comment entirely.","If truncation is the cause, re-export/repair the source file.","Use // line comments instead of /* */ for quick annotations."],"exampleFix":"// before\n{\"a\": 1 /* debug\n// after\n{\"a\": 1 /* debug */}","handlingStrategy":"validation","validationCode":"inBlock := false\nfor i := 0; i < len(data)-1; i++ {\n    if !inBlock && data[i] == '/' && data[i+1] == '*' { inBlock = true; i++ } else if inBlock && data[i] == '*' && data[i+1] == '/' { inBlock = false; i++ }\n}\nif inBlock {\n    return errors.New(\"unterminated /* comment in input\")\n}","typeGuard":null,"tryCatchPattern":"defer func() {\n    if r := recover(); r != nil {\n        if strings.Contains(fmt.Sprint(r), \"end of input in comment\") {\n            err = errors.New(\"close the /* */ comment in the input file\")\n        }\n    }\n}()","preventionTips":["Always close block comments immediately after opening them.","Prefer // line comments for temporary annotations.","Check file completeness when ingesting truncated or streamed data.","Lint JSONC files before parsing."],"tags":["json","comment","unterminated","parser"],"backgroundTag":"unterminated-block-comment","analyzedSha":"4f31cd3a0c5d66f1b4290a2719bab14a5cee8ebe","analyzedAt":"2026-09-02T02:17:47.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}