{"record":{"id":"5f6ff4e661251849","repo":"apache/incubator-seata","slug":"cannot-convert-name-5f6ff4","errorCode":null,"errorMessage":"Cannot convert {name}","messagePattern":"Cannot convert (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"compatible/src/main/java/io/seata/saga/statelang/domain/RecoverStrategy.java","lineNumber":45,"sourceCode":"     */\n    Compensate,\n\n    /**\n     * Forward\n     */\n    Forward;\n\n    public static RecoverStrategy wrap(org.apache.seata.saga.statelang.domain.RecoverStrategy target) {\n        if (target == null) {\n            return null;\n        }\n        switch (target) {\n            case Compensate:\n                return Compensate;\n            case Forward:\n                return Forward;\n            default:\n                throw new IllegalArgumentException(\"Cannot convert \" + target.name());\n        }\n    }\n\n    public org.apache.seata.saga.statelang.domain.RecoverStrategy unwrap() {\n        switch (this) {\n            case Compensate:\n                return org.apache.seata.saga.statelang.domain.RecoverStrategy.Compensate;\n            case Forward:\n                return org.apache.seata.saga.statelang.domain.RecoverStrategy.Forward;\n            default:\n                throw new IllegalArgumentException(\"Cannot convert \" + this.name());\n        }\n    }\n}\n","sourceCodeStart":27,"sourceCodeEnd":60,"githubUrl":"https://github.com/apache/incubator-seata/blob/e01f97c6db397165050caa6764020410c2c8199a/compatible/src/main/java/io/seata/saga/statelang/domain/RecoverStrategy.java#L27-L60","documentation":"Thrown by RecoverStrategy.wrap(org.apache.seata...RecoverStrategy) when converting an Apache Seata RecoverStrategy back to the io.seata compatibility enum and the value falls into the default branch. Only Compensate and Forward exist and both are handled, so the throw signals that the incoming enum class has constants the compatible layer does not know about — i.e. the two artifacts were built from different Seata generations.","triggerScenarios":"Calling RecoverStrategy.wrap(target) where target is an org.apache.seata.saga.statelang.domain.RecoverStrategy constant not present in the switch — only possible when the runtime org.apache.seata jar defines more constants than the compatible io.seata jar was compiled against (version skew), or via a custom-built/hacked enum.","commonSituations":"Mixed io.seata + org.apache.seata jars on one classpath during incremental migration to Apache Seata 2.x; a saga engine module left on an older release while the app core was upgraded; dependency convergence not enforced in a multi-module build.","solutions":["Pin all Seata artifacts (io.seata legacy and/or org.apache.seata) to one consistent release using dependencyManagement / a BOM / Gradle platform.","Exclude the stale transitive saga artifact (e.g. io.seata:seata-saga-statelang) brought in by an older third-party starter.","Add an enforcer rule (requireUpperBoundDeps or dependencyConvergence) so mismatched Seata versions fail the build instead of failing at runtime."],"exampleFix":"// before\n RecoverStrategy wrapped = RecoverStrategy.wrap(apacheStrategy); // throws on skewed jars\n\n// after: align versions, then guard the boundary\n if (apacheStrategy == null\n         || apacheStrategy.name() == null\n         || !Arrays.asList(\"Compensate\", \"Forward\").contains(apacheStrategy.name())) {\n     throw new IllegalStateException(\"Unsupported RecoverStrategy: \" + apacheStrategy);\n }\n RecoverStrategy wrapped = RecoverStrategy.wrap(apacheStrategy);","handlingStrategy":"validation","validationCode":"private static final Set<String> MAPPABLE = Set.of(\"Compensate\", \"Forward\");\n\npublic static RecoverStrategy safeWrap(org.apache.seata.saga.statelang.domain.RecoverStrategy target) {\n    if (target != null && !MAPPABLE.contains(target.name())) {\n        throw new IllegalStateException(\"Unsupported RecoverStrategy: \" + target\n            + \" — mixed io.seata/org.apache.seata versions on classpath\");\n    }\n    return RecoverStrategy.wrap(target);\n}","typeGuard":null,"tryCatchPattern":"try {\n    return RecoverStrategy.wrap(target);\n} catch (IllegalArgumentException e) {\n    throw new IllegalStateException(\"RecoverStrategy '\" + target + \"' unmappable; align Seata versions\", e);\n}","preventionTips":["Pin every Seata artifact to one release in dependencyManagement.","Audit dependency trees for stray io.seata:seata-saga-statelang or old org.apache.seata jars after upgrades.","Keep a project-level test asserting both RecoverStrategy enums enumerate exactly Compensate and Forward."],"tags":["saga","enum","compatibility","version-mismatch"],"backgroundTag":null,"analyzedSha":"e01f97c6db397165050caa6764020410c2c8199a","analyzedAt":"2026-08-14T10:23:53.097Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}