{"record":{"id":"5146c9efeed7c1c9","repo":"fatedier/frp","slug":"unsupported-value-source-type-s-only-file-and","errorCode":null,"errorMessage":"unsupported value source type: %s (only 'file' and 'exec' are supported)","messagePattern":"unsupported value source type: (.+?) \\(only 'file' and 'exec' are supported\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/config/v1/value_source.go","lineNumber":69,"sourceCode":"// Validate validates the ValueSource configuration.\nfunc (v *ValueSource) Validate() error {\n\tif v == nil {\n\t\treturn errors.New(\"valueSource cannot be nil\")\n\t}\n\n\tswitch v.Type {\n\tcase \"file\":\n\t\tif v.File == nil {\n\t\t\treturn errors.New(\"file configuration is required when type is 'file'\")\n\t\t}\n\t\treturn v.File.Validate()\n\tcase \"exec\":\n\t\tif v.Exec == nil {\n\t\t\treturn errors.New(\"exec configuration is required when type is 'exec'\")\n\t\t}\n\t\treturn v.Exec.Validate()\n\tdefault:\n\t\treturn fmt.Errorf(\"unsupported value source type: %s (only 'file' and 'exec' are supported)\", v.Type)\n\t}\n}\n\n// Resolve resolves the value from the configured source.\nfunc (v *ValueSource) Resolve(ctx context.Context) (string, error) {\n\tif err := v.Validate(); err != nil {\n\t\treturn \"\", err\n\t}\n\n\tswitch v.Type {\n\tcase \"file\":\n\t\treturn v.File.Resolve(ctx)\n\tcase \"exec\":\n\t\treturn v.Exec.Resolve(ctx)\n\tdefault:\n\t\treturn \"\", fmt.Errorf(\"unsupported value source type: %s\", v.Type)\n\t}\n}","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/fatedier/frp/blob/6c8a8d0a97d03b44e9528d30b30c70cb9d61b405/pkg/config/v1/value_source.go#L51-L87","documentation":"ValueSource.Validate() rejects a configuration whose `type` field is neither \"file\" nor \"exec\". frp's dynamic value resolution (used for auth tokens, etc.) only supports these two source kinds, so any other string fails fast at validation time rather than at resolve time. The error echoes the offending type so the misconfiguration is immediately visible.","triggerScenarios":"Calling ValueSource.Validate() (directly or transitively via ValueSource.Resolve(ctx)) on a ValueSource with Type set to anything other than \"file\" or \"exec\" — e.g. Type: \"env\", Type: \"secret\", Type: \"\", or a typo like \"File\".","commonSituations":"YAML/JSON frp config uses a valueSource block with an unsupported or misspelled type; a user assumes environment-variable sourcing exists (it does not in this version); an empty type string is left after templating the config.","solutions":["Set type to exactly \"file\" or \"exec\" (lowercase) in the valueSource block.","If you meant to read a token from disk, use type: file together with a file.path entry.","If you meant to run a helper program (e.g. a cloud IAM token fetcher), use type: exec with exec.command and exec.args.","For environment variables, wrap them: use exec with command: sh, args: [-c, \"echo $MY_TOKEN\"]."],"exampleFix":"// before\nValueSource{Type: \"env\"}\n\n// after\nValueSource{Type: \"file\", File: &FileSource{Path: \"/etc/frp/token\"}}","handlingStrategy":"validation","validationCode":"func validateValueSourceType(vs v1.ValueSource) error {\n\tswitch vs.Type {\n\tcase \"file\":\n\t\tif vs.File == nil {\n\t\t\treturn fmt.Errorf(\"type 'file' requires a file block\")\n\t\t}\n\tcase \"exec\":\n\t\tif vs.Exec == nil {\n\t\t\treturn fmt.Errorf(\"type 'exec' requires an exec block\")\n\t\t}\n\tdefault:\n\t\treturn fmt.Errorf(\"unsupported value source type %q (want 'file' or 'exec')\", vs.Type)\n\t}\n\treturn nil\n}","typeGuard":"func isSupportedValueSourceType(t string) bool {\n\treturn t == \"file\" || t == \"exec\"\n}","tryCatchPattern":null,"preventionTips":["Validate ValueSource right after config unmarshal, before frp startup proceeds.","Source the type string only from the constants \"file\"/\"exec\"; never free-form user input.","Add config-lint checks in CI for valueSource blocks."],"tags":["config","validation","frp","value-source"],"backgroundTag":null,"analyzedSha":"6c8a8d0a97d03b44e9528d30b30c70cb9d61b405","analyzedAt":"2026-08-15T06:53:27.215Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}