{"record":{"id":"fa391b9b119b6fc0","repo":"wtfutil/wtf","slug":"s-module-unsupported-protocol-version-s","errorCode":null,"errorMessage":"%s module: Unsupported protocol version: '%s'","messagePattern":"(.+?) module: Unsupported protocol version: '(.+?)'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/ipaddresses/ipinfo/settings.go","lineNumber":40,"sourceCode":"\tcase ipV4:\n\t\treturn \"v4\"\n\tcase ipV6:\n\t\treturn \"v6\"\n\tdefault:\n\t\treturn \"auto\"\n\t}\n}\n\nfunc newProtocolVersion(str string) (protocolVersion, error) {\n\tswitch str {\n\tcase \"v4\":\n\t\treturn ipV4, nil\n\tcase \"v6\":\n\t\treturn ipV6, nil\n\tcase \"auto\":\n\t\treturn auto, nil\n\tdefault:\n\t\treturn \"\", fmt.Errorf(\"%s module: Unsupported protocol version: '%s'\", defaultTitle, str)\n\t}\n}\n\ntype Settings struct {\n\t*cfg.Common\n\n\tapiToken        string          `help:\"An api token\" optional:\"true\"`\n\tprotocolVersion protocolVersion `help:\"IP protocol version to display. Possible options are: 'v4' to show only IpV4 address, 'v6' to show only IpV6 address and 'auto' (default) to show the address preferred by OS.\" optional:\"true\"`\n}\n\nfunc NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {\n\tsettings := Settings{\n\t\tCommon: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),\n\n\t\tapiToken:        ymlConfig.UString(\"apiToken\", \"\"),\n\t\tprotocolVersion: auto,\n\t}\n","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/wtfutil/wtf/blob/bb838c1ccb0f0f3223690df44afdec663d622881/modules/ipaddresses/ipinfo/settings.go#L22-L58","documentation":"newProtocolVersion validates the `protocolVersion` YAML setting of the ipinfo widget and rejects any value other than 'v4', 'v6', or 'auto'. The error names the module (defaultTitle) and echoes the offending string so the bad config value is immediately visible.","triggerScenarios":"NewSettingsFromYAML encounters a settings.protocolVersion value like 'ipv4', 'IPv6', '4', '6', 'both', or an empty/typo'd string instead of exactly v4|v6|auto.","commonSituations":"Typos in the widget YAML (e.g. 'IPV4', 'v 4'), assuming other aliases are accepted, copying config from an older/newer version where the option changed.","solutions":["Set protocolVersion to exactly one of: v4, v6, or auto","Remove the protocolVersion key to fall back to the default","Check the ipinfo widget docs for accepted values"],"exampleFix":"# before\nprotocolVersion: ipv4\n# after\nprotocolVersion: v4","handlingStrategy":"validation","validationCode":"pv := settings.ProtocolVersion\nif pv != \"\" && pv != \"v4\" && pv != \"v6\" && pv != \"auto\" {\n    return fmt.Errorf(\"ipinfo: invalid protocolVersion %q (want v4|v6|auto)\", pv)\n}","typeGuard":"func isValidProtocolVersion(s string) bool {\n    switch s {\n    case \"\", \"v4\", \"v6\", \"auto\":\n        return true\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Copy accepted values (v4/v6/auto) verbatim from the widget docs","Trim whitespace and lowercase YAML values before validation","Add a config lint/test covering every protocolVersion string you ship","Omit the key entirely to use the default"],"tags":["configuration","validation","go","yaml"],"backgroundTag":"invalid-config-value","analyzedSha":"bb838c1ccb0f0f3223690df44afdec663d622881","analyzedAt":"2026-09-03T17:02:45.030Z","contentChangedAt":"2026-09-03T17:02:45.030Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}