{"record":{"id":"8e510b4a1568d95b","repo":"wtfutil/wtf","slug":"azure-subscription-id-is-required-but-not-configur","errorCode":null,"errorMessage":"azure subscription ID is required but not configured","messagePattern":"azure subscription ID is required but not configured","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/azurelogs/query.go","lineNumber":40,"sourceCode":"// TableResp represents the response from an Azure Log Analytics query\ntype TableResp struct {\n\tHeader []string   // Column headers\n\tRows   []TableRow // Data rows\n}\n\n// RunQuery executes an Azure Log Analytics query and returns the formatted results\nfunc RunQuery(sess *Session) (*TableResp, error) {\n\tqf := sess.QueryFile\n\tvar err error\n\tvar tableResp TableResp\n\ttableResp.Header = qf.Columns\n\n\tif qf.WorkspaceID == \"\" {\n\t\treturn nil, fmt.Errorf(\"azure workspace ID is required but not configured\")\n\t}\n\n\tif qf.SubscriptionID == \"\" {\n\t\treturn nil, fmt.Errorf(\"azure subscription ID is required but not configured\")\n\t}\n\n\t// Use read lock first to check if client exists\n\tclientsMutex.RLock()\n\tclient := LogQueryClients[qf.SubscriptionID]\n\tclientsMapExists := LogQueryClients != nil\n\tclientsMutex.RUnlock()\n\n\t// If map doesn't exist or client doesn't exist, we need write access\n\tif !clientsMapExists || client == nil {\n\t\tclientsMutex.Lock()\n\t\t// Double-check after acquiring write lock (double-checked locking pattern)\n\t\tif LogQueryClients == nil {\n\t\t\tLogQueryClients = make(map[string]*azquery.LogsClient)\n\t\t}\n\n\t\tif LogQueryClients[qf.SubscriptionID] == nil {\n\t\t\tLogQueryClients[qf.SubscriptionID], err = CreateLogsClient(sess, qf.SubscriptionID)","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/wtfutil/wtf/blob/bb838c1ccb0f0f3223690df44afdec663d622881/modules/azurelogs/query.go#L22-L58","documentation":"RunQuery in modules/azurelogs/query.go:40 throws this when QueryFile.SubscriptionID is empty. The subscription ID is needed both to select/create the Azure Logs client (LogQueryClients map is keyed by it) and to scope the query request. It is a deliberate early validation before touching the client cache.","triggerScenarios":"Calling RunQuery or fetchDataAsync when the query config YAML does not define subscription-id (or defines it empty), while workspace-id is present — the workspace check at line 36 passed first.","commonSituations":"Config file written for a different cloud/tenant missing the subscription key, placeholder value left unfilled, or case-mismatched YAML key versus the struct's yaml tag so the field stays zero-valued.","solutions":["Set subscription-id: <subscription-guid> in the query config YAML","Confirm the yaml tag on QueryFile.SubscriptionID matches the key in the file","Verify the subscription GUID is correct in the Azure portal and that it hosts the workspace","Log the parsed QueryFile after Init to confirm all required IDs are populated"],"exampleFix":"// before (query.yml)\nworkspace-id: 00000000-0000-0000-0000-000000000000\n// after (query.yml)\nworkspace-id: 00000000-0000-0000-0000-000000000000\nsubscription-id: 11111111-2222-3333-4444-555555555555","handlingStrategy":"validation","validationCode":"if sess.QueryFile.SubscriptionID == \"\" {\n    return errors.New(\"subscription-id missing in query config; set it before RunQuery\")\n}","typeGuard":null,"tryCatchPattern":"tables, err := RunQuery(sess)\nif err != nil {\n    if strings.Contains(err.Error(), \"subscription ID is required\") {\n        return fmt.Errorf(\"config: add subscription-id to %s\", queryPath)\n    }\n    return err\n}","preventionTips":["Add subscription-id to every query file alongside workspace-id","Validate all required IDs immediately after Init in the caller","Copy the subscription GUID from the Azure portal rather than typing it"],"tags":["azure","configuration","log-analytics","validation"],"backgroundTag":"missing-config-field","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"}