{"record":{"id":"1251fbe0d7375d89","repo":"glanceapp/glance","slug":"subreddit-is-required","errorCode":null,"errorMessage":"subreddit is required","messagePattern":"subreddit is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/glance/widget-reddit.go","lineNumber":58,"sourceCode":"\tCommentsURLTemplate string            `yaml:\"comments-url-template\"`\n\tLimit               int               `yaml:\"limit\"`\n\tCollapseAfter       int               `yaml:\"collapse-after\"`\n\tRequestURLTemplate  string            `yaml:\"request-url-template\"`\n\n\tAppAuth struct {\n\t\tName   string `yaml:\"name\"`\n\t\tID     string `yaml:\"id\"`\n\t\tSecret string `yaml:\"secret\"`\n\n\t\tenabled        bool\n\t\taccessToken    string\n\t\ttokenExpiresAt time.Time\n\t} `yaml:\"app-auth\"`\n}\n\nfunc (widget *redditWidget) initialize() error {\n\tif widget.Subreddit == \"\" {\n\t\treturn errors.New(\"subreddit is required\")\n\t}\n\n\tif widget.Limit <= 0 {\n\t\twidget.Limit = 15\n\t}\n\n\tif widget.CollapseAfter == 0 || widget.CollapseAfter < -1 {\n\t\twidget.CollapseAfter = 5\n\t}\n\n\ts := widget.SortBy\n\tif s != \"hot\" && s != \"new\" && s != \"top\" && s != \"rising\" {\n\t\twidget.SortBy = \"hot\"\n\t}\n\n\tp := widget.TopPeriod\n\tif p != \"hour\" && p != \"day\" && p != \"week\" && p != \"month\" && p != \"year\" && p != \"all\" {\n\t\twidget.TopPeriod = \"day\"","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/glanceapp/glance/blob/91324e8de762702e97b0ac5c8e36271d644d8642/internal/glance/widget-reddit.go#L40-L76","documentation":"Thrown by the reddit widget's initialize() when subreddit is empty. The subreddit name drives both the widget title ('r/<name>') and the request URL used to fetch posts, so it is the one required field; sort-by and top-period get defaults instead of erroring.","triggerScenarios":"A widget of type: reddit with no subreddit key; subreddit misspelled (sub-reddit:, sub:); an empty value from a templated/generated config.","commonSituations":"Copy-pasting the reddit widget example and forgetting to fill in the subreddit; multi-subreddit users expecting a list (only a single name is supported here).","solutions":["Set subreddit: to a single community name without the r/ prefix, e.g. subreddit: selfhosted","For multiple communities, add one reddit widget per subreddit","Verify the key is spelled 'subreddit' and top-level within the widget"],"exampleFix":"# before\n- type: reddit\n  sort-by: top\n\n# after\n- type: reddit\n  subreddit: selfhosted\n  sort-by: top","handlingStrategy":"validation","validationCode":"if w['type'] == 'reddit' and not w.get('subreddit'):\n    raise ValueError('reddit widget requires subreddit')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["One subreddit per widget; no r/ prefix, no lists, no +multi syntax","Fill in subreddit immediately after type when adding the widget","Lint required fields for all widget types in a config checker"],"tags":["config","yaml","reddit","validation"],"backgroundTag":null,"analyzedSha":"91324e8de762702e97b0ac5c8e36271d644d8642","analyzedAt":"2026-08-15T14:12:54.279Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}