{"record":{"id":"5c573ac8707a4ae4","repo":"shadow1ng/fscan","slug":"unsupported-format-s","errorCode":null,"errorMessage":"unsupported format: %s","messagePattern":"unsupported format: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/output/manager.go","lineNumber":60,"sourceCode":"func createOutputDir(outputPath string) error {\n\tdir := filepath.Dir(outputPath)\n\treturn os.MkdirAll(dir, DefaultDirPermissions)\n}\n\n// initializeWriter 初始化写入器\nfunc (m *Manager) initializeWriter() error {\n\tvar writer Writer\n\tvar err error\n\n\tswitch m.config.Format {\n\tcase FormatTXT:\n\t\twriter, err = NewTXTWriter(m.config.OutputPath)\n\tcase FormatJSON:\n\t\twriter, err = NewJSONWriter(m.config.OutputPath)\n\tcase FormatCSV:\n\t\twriter, err = NewCSVWriter(m.config.OutputPath)\n\tdefault:\n\t\treturn fmt.Errorf(\"unsupported format: %s\", m.config.Format)\n\t}\n\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tm.writer = writer\n\treturn m.writer.WriteHeader()\n}\n\n// SaveResult 保存扫描结果\nfunc (m *Manager) SaveResult(result *ScanResult) error {\n\tm.mu.RLock()\n\tdefer m.mu.RUnlock()\n\n\tif m.closed {\n\t\treturn fmt.Errorf(\"output manager is closed\")\n\t}","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/shadow1ng/fscan/blob/95cc12e753bf43de7004e5aef42a9ffba3934303/common/output/manager.go#L42-L78","documentation":"Default-branch guard in Manager.initializeWriter: m.config.Format does not match any known output format constant (FormatTXT, FormatJSON, FormatCSV), so no Writer can be constructed for the requested output format string. It indicates a misconfigured/unknown format value passed into the output manager config.","triggerScenarios":"Passing ManagerConfig.Format set to an unknown value (typo like 'jsn', wrong case like 'json' if constants differ, or empty string not handled).","commonSituations":"Hand-written config files or CLI flags feeding a free-form format string, YAML/JSON config with a misspelled format, version change where a format was removed.","solutions":["Use the exported Format constants (FormatTXT/FormatJSON/FormatCSV) instead of raw strings","Check the exact constant spelling/case and correct the config value","Validate/normalize the format string before building ManagerConfig"],"exampleFix":"// before\ncfg.Format = \"json\" // if constant differs\n// after\ncfg.Format = FormatJSON","handlingStrategy":"validation","validationCode":"switch cfg.Format {\ncase FormatTXT, FormatJSON, FormatCSV:\n    // ok\ndefault:\n    return fmt.Errorf(\"format must be one of txt/json/csv, got %q\", cfg.Format)\n}","typeGuard":null,"tryCatchPattern":"mgr, err := NewManager(cfg)\nif err != nil && strings.Contains(err.Error(), \"unsupported format\") {\n    cfg.Format = FormatTXT // safe fallback\n    mgr, err = NewManager(cfg)\n}","preventionTips":["Only assign exported Format constants, never raw strings","Parse config format values through a whitelist/normalizer","Document accepted format values in config schema"],"tags":["output","config","format"],"backgroundTag":"invalid-enum-value","analyzedSha":"95cc12e753bf43de7004e5aef42a9ffba3934303","analyzedAt":"2026-09-06T17:07:30.094Z","contentChangedAt":"2026-09-06T17:07:30.094Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}