{"record":{"id":"d4b12ccfbfcfe908","repo":"antonmedv/fx","slug":"specify-a-file-as-the-first-argument-to-be-able-to","errorCode":null,"errorMessage":"specify a file as the first argument to be able to save: fx file.json ","messagePattern":"specify a file as the first argument to be able to save: fx file\\.json ","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/engine/vm.go","lineNumber":32,"sourceCode":"\tif err := vm.Set(\"__save__\", func(json string) error {\n\t\tif FilePath == \"\" {\n\t\t\treturn fmt.Errorf(\"specify a file as the first argument to be able to save: fx file.json \")\n\t\t}\n\t\tif info, err := os.Lstat(FilePath); err == nil && info.Mode()&os.ModeSymlink != 0 {\n\t\t\treturn fmt.Errorf(\"cannot save to a symbolic link: %s\", FilePath)\n\t\t}\n\t\tif err := os.WriteFile(FilePath, []byte(json), 0644); err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn nil\n\t}); err != nil {\n\t\tpanic(err)\n\t}","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/antonmedv/fx/blob/4f31cd3a0c5d66f1b4290a2719bab14a5cee8ebe/internal/engine/vm.go#L14-L50","documentation":"Raised by the __save__ builtin injected into the JS VM when a script calls save() but the tool was launched without a target file path. It is a generic guard on the global FilePath variable: save() needs a real file to write the JSON payload to, so an empty FilePath means there is nowhere to persist the output and the save is rejected before any write is attempted.","triggerScenarios":"Thrown at internal/engine/vm.go:32 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Run fx with a file argument, e.g. fx file.json","Only call save() when a file argument was supplied","Pass the target path explicitly before invoking save() in the script"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4f31cd3a0c5d66f1b4290a2719bab14a5cee8ebe","analyzedAt":"2026-09-02T02:17:47.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}