shadow1ng/fscan · error
output file not specified
Error message
output file not specified
What it means
Validation guard in InitOutput: file output is enabled (DisableSave is false) but the -o/output file flag (fv.Outputfile) is an empty string, so there is nowhere to write results. It fires before the format switch and means the user must either supply an output path or pass -no to disable saving.
Source
Thrown at common/output_api.go:39
// InitOutput 初始化输出系统
func InitOutput() error {
fv := GetFlagVars()
// silent模式:初始化NDJSON stdout写入器(独立于文件输出)
if fv.Silent {
StdoutWriter = output.NewStdoutNDJSONWriter()
}
// 用户通过-no flag禁用保存时,跳过文件初始化避免不必要的资源开销
if fv.DisableSave {
return nil
}
outputFile := fv.Outputfile
outputFormat := fv.OutputFormat
if outputFile == "" {
return fmt.Errorf("output file not specified")
}
var format output.Format
switch outputFormat {
case "txt":
format = output.FormatTXT
case "json":
format = output.FormatJSON
case "csv":
format = output.FormatCSV
default:
return fmt.Errorf("invalid output format: %s", outputFormat)
}
// 如果使用默认文件名但格式不是txt,自动修正扩展名
if outputFile == "result.txt" && outputFormat != "txt" {
outputFile = "result." + outputFormat
}View on GitHub (pinned to 95cc12e753)
Solutions
- Set the output file flag (-o) or Outputfile field before InitOutput
- Default to a known filename like result.txt when appropriate
- Add pre-validation in the CLI/config layer
Example fix
// before
err := InitOutput(fv) // fv.Outputfile == ""
// after
if fv.Outputfile == "" { fv.Outputfile = "result.txt" }
err := InitOutput(fv) Defensive patterns
Strategy: validation
Validate before calling
if fv.Outputfile == "" {
return errors.New("output file required: use -o <file>")
} Try / catch
if err := InitOutput(fv); err != nil {
if strings.Contains(err.Error(), "output file not specified") {
fv.Outputfile = "result.txt"
err = InitOutput(fv)
}
} Prevention
- Set default output file in CLI flag defaults
- Validate FlagValue before InitOutput
- Document the -o flag as required
When it happens
Trigger: Calling InitOutput without setting the Outputfile field (e.g. missing -o/--output flag or config entry).
Common situations: Users forget the -o flag in CLI mode; config file omits the output-file key; code paths construct FlagValue programmatically and skip Outputfile.
Understand the failure class
Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.
Related errors
- invalid output format: %s
- result cannot be nil
- result cannot be nil
- parser_cidr_failed: %w
- parser_ip_range_failed: %w
AI-assisted analysis of shadow1ng/fscan@95cc12e753 (2026-09-06).
Data as JSON: /api/errors/49175e5657172c3f.
Report an issue: GitHub.