{"record":{"id":"1e21882ae1b5491e","repo":"milvus-io/milvus","slug":"failed-to-push-collection-metrics-command","errorCode":null,"errorMessage":"Failed to push collection metrics command","messagePattern":"Failed to push collection metrics command","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/http/webui/telemetry.html","lineNumber":2758,"sourceCode":"                    },\n                    body: JSON.stringify({\n                        command_type: 'collection_metrics',\n                        target_client_id: targetScope === 'client' ? targetClient : '',\n                        target_database: targetScope === 'database' ? targetDatabase : '',\n                        payload: JSON.stringify(payload),\n                        ttl_seconds: 3600,\n                        persistent: false\n                    })\n                });\n\n                if (resp.status === 401) {\n                    logout();\n                    return;\n                }\n\n                if (!resp.ok) {\n                    const error = await resp.json();\n                    throw new Error(error.error || 'Failed to push collection metrics command');\n                }\n\n                const result = await resp.json();\n\n                // Refresh commands from server\n                await loadServerCommands();\n\n                const action = enabled ? 'enabled' : 'disabled';\n                const collMsg = collections.length > 0 ? ` for: ${collections.join(', ')}` : ' for all';\n                showToast(`Collection metrics ${action}${collMsg}`, 'success');\n            } catch (error) {\n                showToast('Error: ' + error.message, 'error');\n            }\n        }\n\n        async function queryCollectionStatus() {\n            const targetScope = document.getElementById('collectionTargetScope').value;\n            const targetClient = document.getElementById('collectionTargetClient').value;","sourceCodeStart":2740,"sourceCodeEnd":2776,"githubUrl":"https://github.com/milvus-io/milvus/blob/b43a76673a9fe5f01f158979731dc8fd542df81f/internal/http/webui/telemetry.html#L2740-L2776","documentation":"Thrown when POSTing the enable/disable collection-metrics command to /_telemetry/commands fails (non-2xx, non-401). Causes mirror the other command pushes: malformed payload (collections list or interval not accepted), unknown target client/database, or a server-side 500. The server error body is used when present; the literal string is the fallback.","triggerScenarios":"Toggling 'collection metrics' with an empty-but-invalid collections array, non-existent collection names, or a target client that disconnected between page load and submit.","commonSituations":"Collections renamed or dropped after the page loaded; targeting an evicted client; interval/enable payload fields inconsistent with the server's expected schema.","solutions":["Read the toast for the server's error string and correct the offending field (usually collection names or payload shape).","Refresh the client list and collection list, then re-select targets and retry.","If the toast shows the generic fallback, check the response body in devtools Network tab and the proxy logs for a 500."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (!Array.isArray(collections) || collections.some(c => typeof c !== 'string' || !c)) {\n    showToast('Collections list must be non-empty strings', 'error');\n    return;\n}","typeGuard":null,"tryCatchPattern":"try {\n  const resp = await fetch(url, { method: 'POST', headers, body });\n  if (resp.status === 401) { logout(); return; }\n  if (!resp.ok) {\n    const error = await resp.json().catch(() => ({}));\n    throw new Error(error.error || `Failed to push collection metrics command (HTTP ${resp.status})`);\n  }\n} catch (e) { showToast(e.message, 'error'); }","preventionTips":["Re-fetch the collection list before toggling metrics so names are current.","Validate the collections array shape client-side.","Prefer the server's error message over the generic fallback string."],"tags":["javascript","http","telemetry","metrics","commands","webui"],"backgroundTag":null,"analyzedSha":"b43a76673a9fe5f01f158979731dc8fd542df81f","analyzedAt":"2026-08-15T10:29:28.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}