{"record":{"id":"8d5150178681915f","repo":"apache/beam","slug":"failed-to-serialize-object-of-type-s-s","errorCode":null,"errorMessage":"Failed to serialize object of type '%s': %s","messagePattern":"Failed to serialize object of type '(.+?)': (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/azure/src/main/java/org/apache/beam/sdk/io/azure/options/AzureModule.java","lineNumber":226,"sourceCode":"        } else if (tokenCredential instanceof ClientCertificateCredential) {\n          throw new IOException(\"Client certificates not yet implemented\"); // TODO\n        } else if (tokenCredential instanceof UsernamePasswordCredential) {\n          UsernamePasswordCredential credential = (UsernamePasswordCredential) tokenCredential;\n          IdentityClient identityClient = (IdentityClient) getMember(credential, \"identityClient\");\n          jsonGenerator.writeStringField(\n              AZURE_CLIENT_ID, (String) getMember(identityClient, \"clientId\"));\n          jsonGenerator.writeStringField(\n              AZURE_USERNAME, (String) getMember(credential, \"username\"));\n          jsonGenerator.writeStringField(\n              AZURE_PASSWORD, (String) getMember(credential, \"password\"));\n        } else {\n          throw new IOException(\n              String.format(\n                  \"Azure credential provider type '%s' is not supported\",\n                  tokenCredential.getClass().getSimpleName()));\n        }\n      } catch (IllegalAccessException | NoSuchFieldException e) {\n        throw new IOException(\n            String.format(\n                \"Failed to serialize object of type '%s': %s\",\n                tokenCredential.getClass().getSimpleName(), e.toString()));\n      }\n\n      typeSerializer.writeTypeSuffix(jsonGenerator, typeIdDef);\n    }\n  }\n}\n","sourceCodeStart":208,"sourceCodeEnd":236,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/azure/src/main/java/org/apache/beam/sdk/io/azure/options/AzureModule.java#L208-L236","documentation":"serializeWithType reads private fields (identityClient, clientId, etc.) from credential objects via reflection; if that access fails with IllegalAccessException or NoSuchFieldException, it wraps the cause into IOException \"Failed to serialize object of type '%s': %s\". This happens when the Azure SDK identity library's internal field layout changed.","triggerScenarios":"Serializing ClientSecretCredential/UsernamePasswordCredential/AppService MSI credentials against an azure-identity version where the reflected fields ('identityClient', 'clientId', 'username', 'password') were renamed, removed, or made inaccessible (module/JPMS restrictions).","commonSituations":"Upgrading azure-identity in the dependency tree so Beam's AzureModule reflection breaks; running under Java module system strict access; mismatched Beam and azure-identity versions.","solutions":["Pin azure-identity to the version the Beam io-azure module was built against (check beam sdks/java/io/azure build files).","Upgrade the Beam Azure IO module to a release compatible with your azure-identity version.","Avoid pulling a newer azure-identity transitively; align dependencyManagement/force versions.","Use DefaultAzureCredential, whose serialization path avoids deep reflection on these fields."],"exampleFix":"// before (build.gradle)\nimplementation 'com.azure:azure-identity:1.15.0' // field layout changed\n// after\nimplementation('com.azure:azure-identity') {\n  version { strictly('1.11.4') } // matches Beam AzureModule expectations\n}","handlingStrategy":"try-catch","validationCode":"// verify expected internal field exists before serializing\nField f = credential.getClass().getDeclaredField(\"identityClient\"); // NoSuchFieldException => version mismatch","typeGuard":null,"tryCatchPattern":"try {\n  mapper.writeValue(out, options);\n} catch (IOException e) {\n  if (e.getMessage().startsWith(\"Failed to serialize object of type\")) {\n    LOG.error(\"azure-identity version mismatch with Beam AzureModule reflection; pin azure-identity\");\n  }\n  throw e;\n}","preventionTips":["Pin azure-identity to the version Beam io-azure declares","Upgrade Beam io-azure when bumping azure-identity","Watch for transitive azure-identity upgrades in dependency resolution","Prefer DefaultAzureCredential to minimize reflective serialization"],"tags":["java","azure-credentials","serialization","reflection","version-mismatch"],"backgroundTag":"json-marshal-failed","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}