{"record":{"id":"68ebe52de61762f5","repo":"apache/flink","slug":"could-not-register-schema-in-registry","errorCode":null,"errorMessage":"Could not register schema in registry","messagePattern":"Could not register schema in registry","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"flink-formats/flink-avro-confluent-registry/src/main/java/org/apache/flink/formats/avro/registry/confluent/ConfluentSchemaRegistryCoder.java","lineNumber":90,"sourceCode":"\n            try {\n                return schemaRegistryClient.getById(schemaId);\n            } catch (RestClientException e) {\n                throw new IOException(\n                        format(\"Could not find schema with id %s in registry\", schemaId), e);\n            }\n        }\n    }\n\n    @Override\n    public void writeSchema(Schema schema, OutputStream out) throws IOException {\n        try {\n            int registeredId = schemaRegistryClient.register(subject, schema);\n            out.write(CONFLUENT_MAGIC_BYTE);\n            byte[] schemaIdBytes = ByteBuffer.allocate(4).putInt(registeredId).array();\n            out.write(schemaIdBytes);\n        } catch (RestClientException e) {\n            throw new IOException(\"Could not register schema in registry\", e);\n        }\n    }\n}\n","sourceCodeStart":72,"sourceCodeEnd":94,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-formats/flink-avro-confluent-registry/src/main/java/org/apache/flink/formats/avro/registry/confluent/ConfluentSchemaRegistryCoder.java#L72-L94","documentation":"IOException from ConfluentSchemaRegistryCoder.writeSchema when schemaRegistryClient.register(subject, schema) fails with RestClientException during message encoding. Registration is performed lazily on first record write, so DDL validation passes but the job fails at runtime.","triggerScenarios":"First record emitted by an avro-confluent-registry sink when the registry is unreachable, credentials are rejected, or the schema is incompatible with the subject's configured compatibility mode; subjects in read-only mode on hosted registries.","commonSituations":"Schema evolution adding/removing fields under BACKWARD/FULL compatibility policy; wrong basic-auth/TLS settings; Confluent Cloud schema registry with disabled auto-registration.","solutions":["Check the cause RestClientException for the HTTP status: 401/403 = auth or read-only registry, 409 = compatibility violation.","Pre-register the schema (e.g. with a Maven registry plugin or curl POST to /subjects/<subject>/versions) and disable auto-registration if the environment requires it.","Evolve schemas compatibly (add fields with defaults) or reset the subject's compatibility mode deliberately.","Verify registry URL, credentials, and network reachability from TaskManagers."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// pre-flight registration check before starting the job\ntry (CachedSchemaRegistryClient c = new CachedSchemaRegistryClient(url, 100)) {\n    c.register(subject, schema); // fails fast at deploy time instead of first record\n} catch (RestClientException e) {\n    throw new IllegalStateException(\n        \"Cannot register schema under '\" + subject + \"': HTTP \" + e.getStatus(), e);\n}","typeGuard":null,"tryCatchPattern":"try {\n    serializationSchema.open(null);\n    serializationSchema.serialize(row, out);\n} catch (IOException e) {\n    if (e.getMessage().equals(\"Could not register schema in registry\")) {\n        RestClientException rce = (RestClientException) e.getCause();\n        // 401/403 auth or read-only; 409 compatibility conflict\n        log.error(\"Registry registration failed: HTTP {}\", rce.getStatus(), rce);\n    }\n    throw e;\n}","preventionTips":["Pre-register schemas in the registry as part of deployment (schema-registry maven plugin or CI curl).","Evolve schemas compatibly (new fields with defaults) to satisfy BACKWARD/FULL policies.","Verify registry auth settings and that auto.register.schemas is permitted in your environment."],"tags":["avro","confluent","schema-registry","schema-evolution","auth","flink"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}