shadow1ng/fscan · error

portfinger_probe_file_empty

Error message

portfinger_probe_file_empty

What it means

parseProbesFromContent reads the probe database file and collects non-empty lines; if no lines were collected the file is considered empty and this error is returned during Init. It prevents initializing the port fingerprint engine with zero probes.

Source

Thrown at core/portfinger/probe_parser.go:184

// parseProbesFromContent 从内容解析探测器规则,返回错误替代 panic
func (v *VScan) parseProbesFromContent(content string) error {
	var probes []Probe
	var lines []string

	// 过滤注释和空行
	linesTemp := strings.Split(content, "\n")
	for _, lineTemp := range linesTemp {
		lineTemp = strings.TrimSpace(lineTemp)
		if lineTemp == "" || strings.HasPrefix(lineTemp, "#") {
			continue
		}
		lines = append(lines, lineTemp)
	}

	// 验证文件内容
	if len(lines) == 0 {
		return fmt.Errorf("%s", i18n.GetText("portfinger_probe_file_empty"))
	}

	// 检查Exclude指令
	excludeCount := 0
	for _, line := range lines {
		if strings.HasPrefix(line, "Exclude ") {
			excludeCount++
		}
		if excludeCount > 1 {
			return fmt.Errorf("%s", i18n.GetText("portfinger_probe_exclude_duplicate"))
		}
	}

	// 验证第一行格式
	firstLine := lines[0]
	if !strings.HasPrefix(firstLine, "Exclude ") && !strings.HasPrefix(firstLine, "Probe ") {
		return fmt.Errorf("%s", i18n.GetText("portfinger_probe_first_line_invalid"))
	}

View on GitHub (pinned to 95cc12e753)

Solutions

  1. Verify the probe file exists and contains probe lines (e.g. `wc -l probe.txt`), then re-supply it.
  2. Re-download or restore the probe database from the upstream source.
  3. Check Init's file path configuration — ensure it points at the real database, not an empty file.
  4. Add a startup check that rejects zero-byte probe files with a clearer message.

Example fix

// before
err := pf.Init("/etc/app/probes.txt") // probes.txt is 0 bytes
// after
if info, err := os.Stat("/etc/app/probes.txt"); err != nil || info.Size() == 0 {
    return fmt.Errorf("probe database missing or empty")
}
err := pf.Init("/etc/app/probes.txt")
Defensive patterns

Strategy: validation

Validate before calling

st, err := os.Stat(probePath)
if err != nil || st.Size() == 0 {
    return fmt.Errorf("probe file %s missing or empty", probePath)
}

Try / catch

if err := pf.Init(probePath); err != nil {
    if strings.Contains(err.Error(), "probe_file_empty") {
        return fmt.Errorf("probe database at %s is empty; restore it", probePath)
    }
    return err
}

Prevention

When it happens

Trigger: Calling Init with a path to an empty probe file, or a file whose every line was skipped as blank during the read loop.

Common situations: Probe database downloaded incompletely, a file overwritten to zero bytes, wrong path pointing to an empty placeholder, or a failed update that truncated the database.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of shadow1ng/fscan@95cc12e753 (2026-09-06). Data as JSON: /api/errors/75c38d9f2947af67. Report an issue: GitHub.