{"record":{"id":"9ec005a4d2232321","repo":"antonmedv/fx","slug":"cannot-save-to-a-symbolic-link-s","errorCode":null,"errorMessage":"cannot save to a symbolic link: %s","messagePattern":"cannot save to a symbolic link: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/engine/vm.go","lineNumber":35,"sourceCode":"\tCode int\n}\n\nfunc NewVM(writeOut func(string)) *goja.Runtime {\n\tvm := goja.New()\n\n\tif err := vm.Set(\"println\", func(s string) any {\n\t\twriteOut(s)\n\t\treturn nil\n\t}); err != nil {\n\t\tpanic(err)\n\t}\n\n\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}\n\n\tif err := vm.Set(\"__stringify__\", func(x goja.Value) string {\n\t\treturn Stringify(x, vm, 0) + \"\\n\"\n\t}); err != nil {\n\t\tpanic(err)\n\t}\n\n\tif err := vm.Set(\"__toBase64__\", func(x string) string {\n\t\treturn base64.StdEncoding.EncodeToString([]byte(x))\n\t}); err != nil {","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/antonmedv/fx/blob/4f31cd3a0c5d66f1b4290a2719bab14a5cee8ebe/internal/engine/vm.go#L17-L53","documentation":"Refuses to persist output when the target FilePath is a symbolic link, detected via os.Lstat mode bits. This is a deliberate safety guard against accidentally overwriting a file the link points to; the save operation is aborted.","triggerScenarios":"Thrown at internal/engine/vm.go:35 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Save to the real file path instead of the symlink","Remove the symlink and use a regular file","Run fx on the resolved target path directly"],"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"}