{"record":{"id":"0c6d0660a7127af1","repo":"wtfutil/wtf","slug":"failed-to-initialize-azure-session-w","errorCode":null,"errorMessage":"failed to initialize Azure session: %w","messagePattern":"failed to initialize Azure session: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/azurelogs/widget.go","lineNumber":66,"sourceCode":"\tif widget.Disabled() {\n\t\treturn\n\t}\n\n\t// Reset state to allow fresh data fetch\n\twidget.loading = false\n\twidget.lastError = nil\n\twidget.dataLoaded = false\n\twidget.tableData = nil\n\n\twidget.Redraw(widget.content)\n}\n\n/* -------------------- Helper Functions -------------------- */\n\nfunc (widget *Widget) fetchDataAsync() {\n\tsess, err := Init(to.Ptr(widget.settings.Queryfile))\n\tif err != nil {\n\t\twidget.setError(fmt.Errorf(\"failed to initialize Azure session: %w\", err))\n\t\treturn\n\t}\n\n\t// Execute Azure query directly\n\ttableResp, err := RunQuery(sess)\n\tif err != nil {\n\t\twidget.setError(fmt.Errorf(\"failed to execute Azure query: %w\", err))\n\t\treturn\n\t}\n\n\t// Check if we have valid data structure\n\tif tableResp == nil || len(tableResp.Header) == 0 {\n\t\twidget.setError(fmt.Errorf(\"no table structure returned from query\"))\n\t\treturn\n\t}\n\n\t// Store the data and mark as loaded\n\twidget.tableData = tableResp","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/wtfutil/wtf/blob/bb838c1ccb0f0f3223690df44afdec663d622881/modules/azurelogs/widget.go#L48-L84","documentation":"The Azure Logs widget's fetchDataAsync initializes a session with Init(to.Ptr(widget.settings.Queryfile)) before querying. If Init fails (bad queryfile, missing Azure credentials/config) the failure is wrapped as 'failed to initialize Azure session' and surfaced in the widget via setError. It indicates the widget cannot even begin authenticating to Azure.","triggerScenarios":"Init(to.Ptr(widget.settings.Queryfile)) returns an error when the widget renders — e.g. the queryfile setting points to a nonexistent/invalid file, or Azure authentication setup inside Init fails (credentials not configured).","commonSituations":"Wtfutil config missing the azurelogs queryfile setting; invalid YAML/JSON query file; no az login or service-principal env vars in the environment where the dashboard runs.","solutions":["Set a valid Queryfile path in the widget settings and confirm the file exists and parses","Run az login or export AZURE_* service-principal variables for the process running the widget","Call Init() manually with the same queryfile to see the raw underlying error"],"exampleFix":"// before\nsettings.Queryfile = \"\" // unset in config\nsess, err := Init(to.Ptr(widget.settings.Queryfile))\n// after\n// wtfutil config:\n//   queryfile: \"~/.config/wtf/azure-query.yml\"\nsess, err := Init(to.Ptr(widget.settings.Queryfile))\nif err != nil {\n    log.Fatalf(\"azure init: %v\", err)\n}","handlingStrategy":"validation","validationCode":"qf := widget.settings.Queryfile\nif qf == \"\" {\n    return errors.New(\"azurelogs: queryfile not configured\")\n}\nif _, err := os.Stat(qf); err != nil {\n    return fmt.Errorf(\"queryfile %q: %w\", qf, err)\n}","typeGuard":null,"tryCatchPattern":"sess, err := Init(to.Ptr(widget.settings.Queryfile))\nif err != nil {\n    widget.setError(fmt.Errorf(\"failed to initialize Azure session: %w\", err))\n    return\n}","preventionTips":["Validate the queryfile path exists at config load time","Run az login / provision AZURE_* env vars on hosts running the dashboard","Log the underlying Init error, not just the widget-level message"],"tags":["azure","wtfutil","configuration","go"],"backgroundTag":"azure-session-init-failed","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"}