Skip to content
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

Azure schema registry does not work if schema JSON contains newlines #15131

Closed
2 of 6 tasks
dhoepelman opened this issue May 4, 2021 · 13 comments
Closed
2 of 6 tasks
Assignees
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. issue-addressed Workflow: The Azure SDK team believes it to be addressed and ready to close. Schema Registry

Comments

@dhoepelman
Copy link

dhoepelman commented May 4, 2021

  • 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

@ghost ghost added needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels May 4, 2021
@ramya-rao-a ramya-rao-a added Client This issue points to a problem in the data-plane of the library. Schema Registry labels May 4, 2021
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label May 4, 2021
@nguerrera
Copy link
Contributor

@dhoepelman Thanks again for the feedback. I will take a look. I believe this is a response from the service judging from the 400 in the thrown error. Agree this is totally unexpected either way. I'll confirm if it's the service behaving this way and forward the feedback along to the service owners if so. If not, I'll fix it on our side. :)

@nguerrera
Copy link
Contributor

Heads up, @hmlam, I'll let you know what I find, but maybe you've seen something like this already?

@dhoepelman
Copy link
Author

It's not on the server side, because replicating the underlying call with curl works fine if the schema contains newlines

curl --location --request PUT 'https://<my schema registry>.servicebus.windows.net/$schemagroups/<my-schema-group>/schemas/Test?api-version=2017-04' \
--header 'Authorization: Bearer <portal.azure.com token>' \
--header 'x-schema-type: avro' \
--header 'Serialization-Type: avro' \
--header 'Content-Type: application/json' \
--data-raw '{
  "type": "record", 
  "name": "Test", 
  "fields": [{ "name": "X", "type": { "type": "string" } }]
}
'

@nguerrera
Copy link
Contributor

OK, interesting and surprising, I'll dig in. Thank you for the added detail

@nguerrera
Copy link
Contributor

nguerrera commented May 5, 2021

So far, I haven't managed to reproduce this.

When I registered the schema using code above, it succeeded.

@nguerrera
Copy link
Contributor

I'm going to retry with 1.0.0.beta.1, maybe this was fixed since.

@nguerrera
Copy link
Contributor

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

I'm fairly convinced it was #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 [email protected] No description
npm WARN [email protected] No repository field.

+ @azure/[email protected]
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 [email protected] No description
npm WARN [email protected] No repository field.

+ @azure/[email protected]
removed 2 packages, updated 2 packages and audited 1 package in 1.08s
found 0 vulnerabilities


C:\Temp\repro
> node test.js

@dhoepelman
Copy link
Author

Ah ok, npm registry lists 1.0.0-beta.1 as the latest version. Is there any planning to release a new version?

@nguerrera
Copy link
Contributor

Yes, we'll try to push a release. I'll update here when I have an ETA.

@nguerrera nguerrera added bug This issue requires a change to an existing behavior in the product in order to be resolved. and removed question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels May 6, 2021
@ghost ghost added the needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team label May 6, 2021
@ramya-rao-a ramya-rao-a added this to the [2021] June milestone May 10, 2021
@ramya-rao-a ramya-rao-a removed the needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team label May 10, 2021
@ramya-rao-a ramya-rao-a modified the milestones: [2021] June, [2021] July Jun 18, 2021
openapi-sdkautomation bot pushed a commit to AzureSDKAutomation/azure-sdk-for-js that referenced this issue Jul 9, 2021
Azure resource 2021 7 (Azure#15131)

* sql t2 readme config

* readme config

* Update readme.python.md

* conflient resolve

* readme.python config

Co-authored-by: msyyc <[email protected]>
openapi-sdkautomation bot pushed a commit to AzureSDKAutomation/azure-sdk-for-js that referenced this issue Jul 9, 2021
Azure resource 2021 7 (Azure#15131)

* sql t2 readme config

* readme config

* Update readme.python.md

* conflient resolve

* readme.python config

Co-authored-by: msyyc <[email protected]>
openapi-sdkautomation bot pushed a commit to AzureSDKAutomation/azure-sdk-for-js that referenced this issue Jul 9, 2021
Azure resource 2021 7 (Azure#15131)

* sql t2 readme config

* readme config

* Update readme.python.md

* conflient resolve

* readme.python config

Co-authored-by: msyyc <[email protected]>
openapi-sdkautomation bot pushed a commit to AzureSDKAutomation/azure-sdk-for-js that referenced this issue Jul 9, 2021
Azure resource 2021 7 (Azure#15131)

* sql t2 readme config

* readme config

* Update readme.python.md

* conflient resolve

* readme.python config

Co-authored-by: msyyc <[email protected]>
openapi-sdkautomation bot pushed a commit to AzureSDKAutomation/azure-sdk-for-js that referenced this issue Jul 9, 2021
Azure resource 2021 7 (Azure#15131)

* sql t2 readme config

* readme config

* Update readme.python.md

* conflient resolve

* readme.python config

Co-authored-by: msyyc <[email protected]>
openapi-sdkautomation bot pushed a commit to AzureSDKAutomation/azure-sdk-for-js that referenced this issue Jul 9, 2021
Azure resource 2021 7 (Azure#15131)

* sql t2 readme config

* readme config

* Update readme.python.md

* conflient resolve

* readme.python config

Co-authored-by: msyyc <[email protected]>
@deyaaeldeen
Copy link
Member

@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?

@deyaaeldeen
Copy link
Member

@dhoepelman please find the official release out here: https://www.npmjs.com/package/@azure/schema-registry/v/1.0.0-beta.2.

@deyaaeldeen deyaaeldeen added the issue-addressed Workflow: The Azure SDK team believes it to be addressed and ready to close. label Aug 18, 2021
@ghost
Copy link

ghost commented Aug 18, 2021

Hi @dhoepelman. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text “/unresolve” to remove the “issue-addressed” label and continue the conversation.

@ghost
Copy link

ghost commented Aug 25, 2021

Hi @dhoepelman, since you haven’t asked that we “/unresolve” the issue, we’ll close this out. If you believe further discussion is needed, please add a comment “/unresolve” to reopen the issue.

@ghost ghost closed this as completed Aug 25, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2023
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. issue-addressed Workflow: The Azure SDK team believes it to be addressed and ready to close. Schema Registry
Projects
None yet
Development

No branches or pull requests

4 participants