{"record":{"id":"60249600fab5a832","repo":"juicedata/juicefs","slug":"unrecognized-error-handling-value","errorCode":null,"errorMessage":"unrecognized error handling value","messagePattern":"unrecognized error handling value","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdk/java/libjfs/bridge.go","lineNumber":194,"sourceCode":"\t\t\t\tfor k, v := range b.commonLabels {\n\t\t\t\t\tmetric.Label = append(metric.Label, &dto.LabelPair{\n\t\t\t\t\t\tName:  proto.String(k),\n\t\t\t\t\t\tValue: proto.String(v),\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif err != nil || len(mfs) == 0 {\n\t\tswitch b.errorHandling {\n\t\tcase AbortOnError:\n\t\t\treturn err\n\t\tcase ContinueOnError:\n\t\t\tif b.logger != nil {\n\t\t\t\tb.logger.Println(\"continue on error:\", err)\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(\"unrecognized error handling value\")\n\t\t}\n\t}\n\n\tconn, err := net.DialTimeout(\"tcp\", b.url, b.timeout)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer conn.Close()\n\n\treturn writeMetrics(conn, mfs, b.useTags, b.prefix, model.Now())\n}\n\nfunc writeMetrics(w io.Writer, mfs []*dto.MetricFamily, useTags bool, prefix string, now model.Time) error {\n\tvec, err := expfmt.ExtractSamples(&expfmt.DecodeOptions{\n\t\tTimestamp: now,\n\t}, mfs...)\n\tif err != nil {\n\t\treturn err","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/sdk/java/libjfs/bridge.go#L176-L212","documentation":"Raised by the Java bridge's Push method in sdk/java/libjfs/bridge.go:194. Push takes an error-handling mode; when the mode is not Stop or ContinueOnError, the code panics with this message. This is a programming/configuration error in the caller of the bridge, not a runtime data error — the bridge only recognizes its defined errorHandling values.","triggerScenarios":"Invoking bridge Push (e.g. from Java via JNI for juicefs sync) with an unrecognized errorHandling value — typically a wrong integer constant passed across the JNI boundary or a stale/unsupported enum value from the Java side.","commonSituations":"Java SDK versions mismatched with the native library (libjfs.so) so the errorHandling enum codes disagree; hand-written JNI callers passing 2/other values instead of 0 (Stop) or 1 (ContinueOnError).","solutions":["Pass only the recognized values: the constant for Stop (0) or ContinueOnError (1) as defined in the bridge.","Use the Java SDK's enum/constant helpers instead of raw integers when calling Push.","Align the Java SDK and native libjfs library versions so errorHandling codes match.","Add validation on the Java side to reject unknown modes before crossing the JNI boundary."],"exampleFix":"// before\nbridge.Push(cfg, 7) // unknown handling value -> panic\n\n// after\nbridge.Push(cfg, bridge.ContinueOnError) // recognized constant","handlingStrategy":"validation","validationCode":"// Java side, before calling Push\nif (errorHandling != ERROR_HANDLING_STOP && errorHandling != ERROR_HANDLING_CONTINUE) {\n    throw new IllegalArgumentException(\"errorHandling must be 0 (stop) or 1 (continue-on-error), got \" + errorHandling);\n}","typeGuard":null,"tryCatchPattern":"// Go side, defensively validate before the bridge switch\nif h != Stop && h != ContinueOnError {\n    return fmt.Errorf(\"unsupported error handling value: %v\", h)\n}","preventionTips":["Always use named constants/enums instead of raw integers across the JNI boundary.","Keep the Java SDK and native libjfs binary from the same release.","Add unit tests covering every enum value the Java layer can pass."],"tags":["java","jni","bridge","enum","panic"],"backgroundTag":"invalid-enum-value","analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}