{"record":{"id":"319eaa501f35eed1","repo":"shadow1ng/fscan","slug":"webscan-xray-format-parse-failed","errorCode":"webscan_xray_format_parse_failed","errorMessage":"webscan_xray_format_parse_failed: %w","messagePattern":"webscan_xray_format_parse_failed: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"webscan/lib/poc_adapter.go","lineNumber":428,"sourceCode":"\t\tMethod          string            `yaml:\"method\"`\n\t\tPath            string            `yaml:\"path\"`\n\t\tHeaders         map[string]string `yaml:\"headers\"`\n\t\tBody            string            `yaml:\"body\"`\n\t\tFollowRedirects bool              `yaml:\"follow_redirects\"`\n\t} `yaml:\"request\"`\n\tExpression string                 `yaml:\"expression\"`\n\tOutput     map[string]interface{} `yaml:\"output\"`\n}\n\n// XrayPocAdapter xray格式适配器\ntype XrayPocAdapter struct {\n\t*XrayPoc\n}\n\nfunc loadXrayPoc(data []byte) (*XrayPocAdapter, error) {\n\tvar poc XrayPoc\n\tif err := yaml.Unmarshal(data, &poc); err != nil {\n\t\treturn nil, fmt.Errorf(\"%s: %w\", i18n.GetText(\"webscan_xray_format_parse_failed\"), err)\n\t}\n\treturn &XrayPocAdapter{&poc}, nil\n}\n\n// GetName 获取POC名称\nfunc (x *XrayPocAdapter) GetName() string {\n\treturn x.Name\n}\n\n// GetFormat 获取POC格式类型\nfunc (x *XrayPocAdapter) GetFormat() PocFormat {\n\treturn FormatXray\n}\n\n// ToFscanPoc 将xray格式转换为fscan格式\nfunc (x *XrayPocAdapter) ToFscanPoc() (*Poc, error) {\n\tpoc := &Poc{\n\t\tName:   x.Name,","sourceCodeStart":410,"sourceCodeEnd":446,"githubUrl":"https://github.com/shadow1ng/fscan/blob/95cc12e753bf43de7004e5aef42a9ffba3934303/webscan/lib/poc_adapter.go#L410-L446","documentation":"loadXrayPoc wraps errors returned by yaml.Unmarshal when parsing an Xray-format POC file into the XrayPoc struct. The message combines the localized 'webscan_xray_format_parse_failed' text with the underlying yaml error (%w), so the real cause is in the wrapped error. It means the POC data is not valid YAML or does not match the XrayPoc schema.","triggerScenarios":"Calling LoadUniversalPoc, TestXrayOutputToSearch, or TestXrayNoOutput with POC bytes that yaml.Unmarshal cannot decode into *XrayPoc (malformed YAML syntax, wrong indentation, tabs, or fields of incompatible types).","commonSituations":"POC files edited by hand introducing tab indentation or bad types (e.g. a string where a list is expected); downloaded Xray POCs in JSON-only or truncated form; encoding issues (BOM, non-UTF8); empty file passed in.","solutions":["Inspect the wrapped yaml error after the ': %w' portion — it gives the exact line/column of the parse failure","Fix the YAML syntax at that line (replace tabs with spaces, correct indentation, quote strings that look like other types)","Validate the POC file with a standalone YAML parser before feeding it to the library","Ensure the file is valid UTF-8 without BOM and non-empty"],"exampleFix":"// before: poc.yaml with tab indentation\nrules:\n\t- method: GET\n// after\nrules:\n  - method: GET","handlingStrategy":"try-catch","validationCode":"if len(data) == 0 { return errors.New(\"empty POC data\") }\nif err := yaml.Unmarshal(data, &map[string]any{}); err != nil {\n    return fmt.Errorf(\"POC is not valid YAML: %w\", err)\n}","typeGuard":"func looksLikeYAML(data []byte) bool {\n    return len(bytes.TrimSpace(data)) > 0 && !bytes.HasPrefix(bytes.TrimSpace(data), []byte(\"{\\\"\"))\n}","tryCatchPattern":"poc, err := LoadUniversalPoc(data)\nif err != nil {\n    if strings.Contains(err.Error(), \"webscan_xray_format_parse_failed\") {\n        log.Warnf(\"bad xray POC: %v\", err) // skip, don't crash\n        return nil\n    }\n    return err\n}","preventionTips":["Run all POC files through a YAML parser in CI","Use spaces, never tabs, in POC files","Keep POC files UTF-8 without BOM","Pin POC files to schema versions you tested"],"tags":["yaml","poc","parsing"],"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"}