shadow1ng/fscan · error
webscan_xray_format_parse_failed
webscan_xray_format_parse_failed
Error message
webscan_xray_format_parse_failed: %w
What it means
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.
Source
Thrown at webscan/lib/poc_adapter.go:428
Method string `yaml:"method"`
Path string `yaml:"path"`
Headers map[string]string `yaml:"headers"`
Body string `yaml:"body"`
FollowRedirects bool `yaml:"follow_redirects"`
} `yaml:"request"`
Expression string `yaml:"expression"`
Output map[string]interface{} `yaml:"output"`
}
// XrayPocAdapter xray格式适配器
type XrayPocAdapter struct {
*XrayPoc
}
func loadXrayPoc(data []byte) (*XrayPocAdapter, error) {
var poc XrayPoc
if err := yaml.Unmarshal(data, &poc); err != nil {
return nil, fmt.Errorf("%s: %w", i18n.GetText("webscan_xray_format_parse_failed"), err)
}
return &XrayPocAdapter{&poc}, nil
}
// GetName 获取POC名称
func (x *XrayPocAdapter) GetName() string {
return x.Name
}
// GetFormat 获取POC格式类型
func (x *XrayPocAdapter) GetFormat() PocFormat {
return FormatXray
}
// ToFscanPoc 将xray格式转换为fscan格式
func (x *XrayPocAdapter) ToFscanPoc() (*Poc, error) {
poc := &Poc{
Name: x.Name,View on GitHub (pinned to 95cc12e753)
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
Example fix
// before: poc.yaml with tab indentation rules: - method: GET // after rules: - method: GET
Defensive patterns
Strategy: try-catch
Validate before calling
if len(data) == 0 { return errors.New("empty POC data") }
if err := yaml.Unmarshal(data, &map[string]any{}); err != nil {
return fmt.Errorf("POC is not valid YAML: %w", err)
} Type guard
func looksLikeYAML(data []byte) bool {
return len(bytes.TrimSpace(data)) > 0 && !bytes.HasPrefix(bytes.TrimSpace(data), []byte("{\""))
} Try / catch
poc, err := LoadUniversalPoc(data)
if err != nil {
if strings.Contains(err.Error(), "webscan_xray_format_parse_failed") {
log.Warnf("bad xray POC: %v", err) // skip, don't crash
return nil
}
return err
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- webscan_poc_convert_failed
- webscan_unknown_poc_format
- webscan_fscan_format_parse_failed
- webscan_nuclei_format_parse_failed
- %s: %w (webscan_afrog_format_parse_failed)
AI-assisted analysis of shadow1ng/fscan@95cc12e753 (2026-09-06).
Data as JSON: /api/errors/319eaa501f35eed1.
Report an issue: GitHub.