{"record":{"id":"d6d7145ea136e181","repo":"prometheus/node_exporter","slug":"unexpected-type-t","errorCode":null,"errorMessage":"unexpected type %T","messagePattern":"unexpected type %T","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/sysctl_linux.go","lineNumber":216,"sourceCode":"func (s *sysctl) newMappedMetrics(v any) ([]prometheus.Metric, error) {\n\tswitch values := v.(type) {\n\tcase []int:\n\t\tmetrics := make([]prometheus.Metric, len(values))\n\t\tfor i, n := range values {\n\t\t\tkey := s.keys[i]\n\t\t\tdesc := prometheus.NewDesc(\n\t\t\t\tprometheus.BuildFQName(namespace, \"sysctl\", s.metricName()+\"_\"+key),\n\t\t\t\tfmt.Sprintf(\"sysctl %s, field %d\", s.name, i),\n\t\t\t\tnil,\n\t\t\t\tnil,\n\t\t\t)\n\t\t\tmetrics[i] = prometheus.MustNewConstMetric(desc, prometheus.UntypedValue, float64(n))\n\t\t}\n\t\treturn metrics, nil\n\tcase []string:\n\t\treturn nil, fmt.Errorf(\"mapped sysctl string values not supported\")\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unexpected type %T\", values)\n\t}\n}\n","sourceCodeStart":198,"sourceCodeEnd":219,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/sysctl_linux.go#L198-L219","documentation":"newMappedMetrics received a value type that is neither []int nor []string. Given newMetrics only produces those two types, reaching this default branch signals an internal invariant violation in the collector.","triggerScenarios":"Should be unreachable in normal operation; would require newMetrics returning a value slice of an unexpected type into newMappedMetrics.","commonSituations":"Only after local modifications to the collector or a procfs library change returning a novel slice type.","solutions":["File/inspect an upstream issue with the sysctl name and Go type printed in the message","Pin/verify the prometheus/procfs version used at build time","Add handling for the new type in newMappedMetrics if patching locally"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"unexpected type\") {\n    logger.Error(\"sysctl collector invariant violated\", \"err\", err) // report upstream\n}","preventionTips":["Avoid local forks that change value types in newMetrics","Keep node_exporter and prometheus/procfs at pinned, tested versions","Treat this as a bug report trigger, not a config issue"],"tags":["linux","sysctl","internal","type-mismatch"],"backgroundTag":"internal-invariant-violation","analyzedSha":"17ddd77c59ba27e1508e9f7894b1e55b44d6aed3","analyzedAt":"2026-09-07T17:54:06.211Z","contentChangedAt":"2026-09-07T17:54:06.211Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}