{"record":{"id":"a824fa9e3adaee14","repo":"alibaba/spring-ai-alibaba","slug":"unknown-object-method","errorCode":null,"errorMessage":"Unknown Object method: ","messagePattern":"Unknown Object method: ","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spring-boot-starters/spring-ai-alibaba-starter-config-nacos/src/main/java/com/alibaba/cloud/ai/agent/nacos/utils/ChatOptionsProxy.java","lineNumber":205,"sourceCode":"\t\t\tcase \"toString\":\n\t\t\t\treturn \"CglibProxy{\" +\n\t\t\t\t\t\t\"chatOptions=\" + chatOptions +\n\t\t\t\t\t\t\", observationMetadata=\" + observationMetadata +\n\t\t\t\t\t\t\", observationName='\" + observationName + '\\'' +\n\t\t\t\t\t\t\", observationEnabled=\" + observationEnabled +\n\t\t\t\t\t\t'}';\n\n\t\t\tcase \"equals\":\n\t\t\t\tif (args != null && args.length > 0) {\n\t\t\t\t\treturn obj == args[0];\n\t\t\t\t}\n\t\t\t\treturn false;\n\n\t\t\tcase \"hashCode\":\n\t\t\t\treturn System.identityHashCode(obj);\n\n\t\t\tdefault:\n\t\t\t\tthrow new UnsupportedOperationException(\"Unknown Object method: \" + methodName);\n\t\t\t}\n\t\t}\n\t}\n}\n","sourceCodeStart":187,"sourceCodeEnd":210,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-boot-starters/spring-ai-alibaba-starter-config-nacos/src/main/java/com/alibaba/cloud/ai/agent/nacos/utils/ChatOptionsProxy.java#L187-L210","documentation":"The proxy's handleObjectMethod special-cases the core Object methods it supports (toString, equals, hashCode). Any other Object-level method invoked through the proxy — e.g. clone(), finalize(), notify() — reaches the default branch and throws UnsupportedOperationException('Unknown Object method: ' + name).","triggerScenarios":"Calling an Object method other than toString/equals/hashCode on a ChatOptionsProxy instance, e.g. options.clone(), or framework/util code calling getClass()-adjacent methods through the proxy interface.","commonSituations":"Deep-copy utilities or serialization frameworks that call clone() on the options; debuggers/collection code invoking unexpected Object methods; developer code assuming the proxy behaves like the original object for all methods.","solutions":["Do not call clone() or other unsupported Object methods on the proxy; clone/copy the underlying ChatOptions instance instead.","If a specific Object method is needed, add a case for it in ChatOptionsProxy.handleObjectMethod.","Unwrap the proxy to the real ChatOptions before passing it to utilities that expect full Object semantics."],"exampleFix":"// before\nMyOptions copy = (MyOptions) proxiedOptions.clone(); // throws\n// after\nMyOptions copy = underlyingOptions.copy(); // use the real instance","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"static ChatOptions unwrap(Object maybeProxy) {\n    return (maybeProxy instanceof ChatOptionsProxy.ProxyRef pr) ? pr.target() : (ChatOptions) maybeProxy;\n}\n// use unwrap() before clone()/other Object methods","tryCatchPattern":"try { return proxied.equals(other); }\ncatch (UnsupportedOperationException e) {\n    if (e.getMessage().startsWith(\"Unknown Object method\")) { return underlying.equals(other); }\n    throw e;\n}","preventionTips":["Only rely on toString/equals/hashCode through the proxy","Perform clone/copy on the original ChatOptions, not the proxy","Keep a reference to the unproxied options instance alongside the proxy"],"tags":["dynamic-proxy","object-methods","unsupported-operation","java"],"backgroundTag":"unsupported-operation","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}