-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GoError: Failed to encode data, OriginalError: cannot decode textual record #285
Comments
Hey @Shabda1988, See if this #266 (comment) solves your problem. |
Hey @mostafa thanks for replying . I tried the way by appending the namespace to the field in data body and after running , error shifted to other field ....other field also had same namespace but when i appended the namespace name to that field and re ran again , error came for the first field again giving the same reason Let me know if you understood it :) |
@Shabda1988 |
@mostafa I cant give the whole avro but posting here a part of it with modified names .
Sample data : `{ "book": { }` This is just a small part of a big thing.. see if it helps . |
@mostafa Let me know if its fine or is it possible we can get on some call . Schema is very big around 6k lines and same is the case with data which i am trying to post ...so its becoming difficult to understand what and where to change and why the issue is happening. |
@mostafa Can you please help with the above provided schema and sample data provided . |
Hey @Shabda1988, I created a small tool to test your schema and data outside xk6-kafka and made it ready to be ingested into your script as is: https://github.com/mostafa/nested-avro-schema. I also provided an example Avro schema and data in the |
@mostafa Thanks a lot for creating this utility . Its very easy to use and it pinpoints where the issue is and what needs to be done for that field . It fixed my issue and now am able to post message on kafka topic . Very nice utility . Thank you for creating . |
@Shabda1988 Happy that I have been of help and that your issue is resolved. |
Hi team,
Here is my code snippet
Data body was long ..so i just commented data there ...let me know if data body is required .
I am getting below error while running the k6 script .
`import {LoadJKS,
TLS_1_2,
SASL_SCRAM_SHA512,
Writer,
SchemaRegistry,
SCHEMA_TYPE_AVRO,
KEY,
VALUE,
RECORD_NAME_STRATEGY} from "k6/x/kafka"; // import kafka extension
import { check } from "k6";
const surl="https://schema-registry-url";
const topic = "topic";
const jks = LoadJKS({
path: "./keystore-sr.jks",
password: "password1",
clientCertAlias: "alias1",
clientKeyAlias: "alias1",
clientKeyPassword: "password1",
});
const jks1 = LoadJKS({
path: "./truststore.jks",
password: "password2",
serverCaAlias: "serveralias"
});
const tlsConfig = {
enableTls: true,
insecureSkipTlsVerify: false,
minVersion: TLS_1_2,
clientCertPem: jks["clientCertsPem"][0], // The first certificate in the chain
clientKeyPem: jks["clientKeyPem"],
serverCaPem: jks1["serverCaPem"],
};
const saslConfig= {
username: "demo-username",
password: "sasl-password",
algorithm: SASL_SCRAM_SHA512,
}
const writer = new Writer({
brokers: ["broker:443"],
topic: topic,
sasl: saslConfig,
tls: tlsConfig
});
const schemaRegistry = new SchemaRegistry({
url: surl,
tls: tlsConfig
});
const valueSchemaObject = schemaRegistry.getSchema({
subject: '${topic}-value',
schemaType: SCHEMA_TYPE_AVRO,
});
export default function () {
try{ {
let messages = [
{
} }
catch (e) {
console.error('Unhandled exception');
console.log(e);
console.log(e.stack);
console.log(JSON.stringify(e));
}
}`
{"value":{"code":2001,"message":"Failed to encode data","original_error":{}}} source=console INFO[0004] GoError: Failed to encode data, OriginalError: cannot decode textual record "com.m.Plan": cannot decode textual union: cannot decode textual map: cannot determine codec: "bookingNumber" for key: "booking" at github.com/mostafa/xk6-kafka.(*Kafka).schemaRegistryClientClass.func4 (native) at file:///C:/Users/SAD121/OneDrive%20-%20Maersk%20Group/Desktop/jksfile/kafka1.js:78:40(2459) source=console INFO[0004] {"value":{"code":2001,"message":"Failed to encode data","original_error":{}}} source=console INFO[0004] 2024/04/23 17:11:00 No server's CA alias provided, skipping server's CA
The text was updated successfully, but these errors were encountered: