question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Azure schema registry does not work if schema JSON contains newlines

See original GitHub issue
  • Package Name: @azure/schema-registry
  • Package Version: 1.0.0-beta.1
  • Operating system: OS X 11.2
  • nodejs
    • version: v14.15.4
  • browser
    • name/version:
  • typescript
    • version: 4.1.3
  • Is the bug related to documentation in

Describe the bug

The azure schema registry does not function if the schema content contains newlines

To Reproduce Steps to reproduce the behavior: 1.

await new SchemaRegistryClient(..., new DefaultAzureCredential()).getSchemaId({
  group: 'test'
  name: 'Test',
  serializationType: 'avro',
  content: '{\n' +
      '  "type": "record",\n' +
      '  "name": "Test",\n' +
      '  "fields": [{ "name": "X", "type": { "type": "string" } }]\n' +
      '}\n'
})

// will always return rejected promise with schema not found

or

await new SchemaRegistryClient(..., new DefaultAzureCredential()).registerSchema({
  group: 'test'
  name: 'Test',
  serializationType: 'avro',
  content: '{\n' +
      '  "type": "record",\n' +
      '  "name": "Test",\n' +
      '  "fields": [{ "name": "X", "type": { "type": "string" } }]\n' +
      '}\n'
})

// will throw error
// RestError: {"Code":400,"Detail":"Schema validation failed: Invalid character after parsing property name. Expected ':' but got: \". Path '', line 1, position 4.

Expected behavior

Schema newlines (and whitespace) should not affect the API, as long as it results in the equivalent JSON

At the very minimum, this should have some major warnings in the SDK docs and typings

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:13 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
deyaaeldeencommented, Aug 5, 2021

@dhoepelman Hi, @nguerrera fixed this issue and is scheduled to be part of the v1.0.0-beta.2 happening this month. For now, could you please try this alpha version?

1reaction
nguerreracommented, May 5, 2021

Yep, something fixed this between 1.0.0-beta.1 and now! 😁

I’m fairly convinced it was https://github.com/Azure/azure-sdk-for-js/pull/11650. There had been some issues with the swagger and autorest around the body being a raw string. Also, there really hasn’t been any other interesting changes since beta 1.

C:\Temp\repro
> cat test.js
const { SchemaRegistryClient } = require("@azure/schema-registry");
const { DefaultAzureCredential } = require("@azure/identity");
const dotenv = require("dotenv");
dotenv.config();


new SchemaRegistryClient("https://nicholgsrplayground.servicebus.windows.net", new DefaultAzureCredential()).registerSchema({
  group: 'azsdk_js_test_group',
  name: 'Test',
  serializationType: 'avro',
  content: '{\n' +
      '  "type": "record",\n' +
      '  "name": "Test",\n' +
      '  "fields": [{ "name": "X", "type": { "type": "string" } }]\n' +
      '}\n'
}).catch((e) => {console.error(e.stack); process.exit(1)});

C:\Temp\repro
> npm install @azure/schema-registry
npm WARN repro@1.0.0 No description
npm WARN repro@1.0.0 No repository field.

+ @azure/schema-registry@1.0.0-beta.1
updated 1 package and audited 33 packages in 1.215s
found 0 vulnerabilities


C:\Temp\repro
> node test.js
RestError: {"Code":400,"Detail":"Schema validation failed: Invalid character after parsing property name. Expected ':' but got: \". Path '', line 1, position 4. TrackingId:83146526-9197-49cc-acd5-16678d07e1e9_G11, SystemTracker:nicholgsrplayground.servicebus.windows.net:$schemagroups\/azsdk_js_test_group\/schemas\/Test, Timestamp:2021-05-05T21:57:18"}
    at new RestError (C:\Temp\repro\node_modules\@azure\core-http\dist\index.js:2362:28)
    at handleErrorResponse (C:\Temp\repro\node_modules\@azure\core-http\dist\index.js:3246:17)
    at C:\Temp\repro\node_modules\@azure\core-http\dist\index.js:3182:18
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

C:\Temp\repro
> npm install C:\src\azure-sdk-for-js\sdk\schemaregistry\schema-registry\azure-schema-registry-1.0.0-beta.2.tgz
npm WARN repro@1.0.0 No description
npm WARN repro@1.0.0 No repository field.

+ @azure/schema-registry@1.0.0-beta.2
removed 2 packages, updated 2 packages and audited 1 package in 1.08s
found 0 vulnerabilities


C:\Temp\repro
> node test.js

Read more comments on GitHub >

github_iconTop Results From Across the Web

Schema Registry API Reference
To use a multi-line example as a copy-paste test of an API, remove the newlines before running it so as not to trigger...
Read more >
Loading JSON data from Cloud Storage | BigQuery
You can load newline delimited JSON data from Cloud Storage into a new table ... BigQuery supports the JSON type even if schema...
Read more >
Kafka Producer
Avro schema subject to look up or to register in Confluent Schema Registry. If the specified subject to look up has multiple schema...
Read more >
from_json function | Databricks on AWS
To keep corrupt records, you can set a string type field named columnNameOfCorruptRecord in an user-defined schema. If a schema does not have...
Read more >
Schema Registry integration
The following example statements show how to create streams and tables that have Avro-formatted data. If you want to use Protobuf- or JSON- ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found