{"record":{"id":"d2a7277b96ec9be7","repo":"shadow1ng/fscan","slug":"webscan-fscan-format-parse-failed","errorCode":"webscan_fscan_format_parse_failed","errorMessage":"webscan_fscan_format_parse_failed: %w","messagePattern":"webscan_fscan_format_parse_failed: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"webscan/lib/poc_adapter.go","lineNumber":147,"sourceCode":"\t\treturn loadXrayPoc(data)\n\tcase FormatAfrog:\n\t\treturn loadAfrogPoc(data)\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"%s: %s\", i18n.GetText(\"webscan_unknown_poc_format\"), filename)\n\t}\n}\n\n// ============= fscan格式适配器 =============\n\n// FscanPocAdapter fscan原生格式适配器\ntype FscanPocAdapter struct {\n\t*Poc\n}\n\nfunc loadFscanPoc(data []byte) (*FscanPocAdapter, error) {\n\tvar poc Poc\n\tif err := yaml.Unmarshal(data, &poc); err != nil {\n\t\treturn nil, fmt.Errorf(\"%s: %w\", i18n.GetText(\"webscan_fscan_format_parse_failed\"), err)\n\t}\n\treturn &FscanPocAdapter{&poc}, nil\n}\n\n// GetName 获取POC名称\nfunc (f *FscanPocAdapter) GetName() string {\n\treturn f.Name\n}\n\n// GetFormat 获取POC格式类型\nfunc (f *FscanPocAdapter) GetFormat() PocFormat {\n\treturn FormatFscan\n}\n\n// ToFscanPoc 转换为Fscan POC格式\nfunc (f *FscanPocAdapter) ToFscanPoc() (*Poc, error) {\n\treturn f.Poc, nil\n}","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/shadow1ng/fscan/blob/95cc12e753bf43de7004e5aef42a9ffba3934303/webscan/lib/poc_adapter.go#L129-L165","documentation":"loadFscanPoc unmarshals fscan-format POC bytes into the Poc struct with yaml.Unmarshal. On any YAML syntax or schema error the failure is wrapped as webscan_fscan_format_parse_failed. The adapter layer uses this so callers get a contextual message instead of a bare yaml error.","triggerScenarios":"LoadUniversalPoc detects FormatFscan and the data fails yaml.Unmarshal: invalid YAML syntax, wrong types for Poc fields (e.g., string where int expected), duplicate keys, tabs for indentation.","commonSituations":"Hand-edited fscan POC files with indentation mistakes; POCs exported from other tools whose fields don't match the Poc struct; version changes where Poc struct fields were renamed or retyped.","solutions":["Validate the YAML with a linter (yamllint) — fix indentation/tabs/syntax errors first.","Compare field names/types against the Poc struct definition in poc_adapter.go and a known-good fscan POC.","Run the file through yaml.Unmarshal in a scratch test to see the wrapped underlying error.","Re-export or update the POC if it targets an older struct schema."],"exampleFix":"// before\n// rules:\n//\t- method: GET   <- tab indentation -> YAML parse error\n\n// after\n// rules:\n//   - method: GET  <- spaces, valid YAML","handlingStrategy":"validation","validationCode":"var probe map[string]interface{}\nif err := yaml.Unmarshal(data, &probe); err != nil {\n    return fmt.Errorf(\"invalid YAML: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"poc, err := loadFscanPoc(data)\nif err != nil {\n    return fmt.Errorf(\"fscan POC parse: %w\", err)\n}","preventionTips":["Run yamllint on POC files; never indent with tabs.","Keep POC field names/types in sync with the Poc struct.","Validate new POCs in a unit test (like TestFscanPocAdapter) before shipping."],"tags":["poc","yaml","unmarshal","fscan"],"backgroundTag":"yaml-parse-error","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"}