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

Cannot create subscription inside topic in Azure Service Bus (JavaScript) #30979

Closed
6 tasks
CezaryBD opened this issue Sep 3, 2024 · 7 comments
Closed
6 tasks
Assignees
Labels
Azure.Core Client This issue points to a problem in the data-plane of the library. Service Bus

Comments

@CezaryBD
Copy link

CezaryBD commented Sep 3, 2024

  • Package Name: @azure/service-bus
  • Package Version: ^7.9.5
  • Operating system: macOS 14.6.1 (but tested on Windows 11 - not working as well)
  • nodejs
    • version: v20.10.0
  • browser
    • name/version: Mozilla Firefox 130 but also 115
  • typescript
    • version: ^5.0.4
  • Is the bug related to documentation in

Describe the bug
The bug is happening on Mozilla Firefox browser only (so far).
It seems that while executing subscription creation, there is a problem with xml payload created only on Mozilla Firefox browser.

To Reproduce
Steps to reproduce the behavior:

  1. Create subscription like:
this._sbAdminClient.createSubscription(
                        `myApp-${user}`, 
                        azureSubscriptionId,
                        {
                            autoDeleteOnIdle: 'PT1H',
                        }
                    )
// {user} variable here is just a simple string and it does contain only simple latin characters

Expected behavior
Fix ASAP Mozilla Firefox integration with your library or provide a workaround.

Screenshots
n/a

Additional context
XML faulty payload generated by Firefox:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<entry>
    <updated>2024-09-03T07:41:08.210Z</updated>
    <content type="application/xml">
        <SubscriptionDescription
            xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
            <AutoDeleteOnIdle>PT1H</AutoDeleteOnIdle>
        </SubscriptionDescription>
    </content>
</entry>

Response:
400 BAD_REQUEST
Body:

<Error>
<Code>400</Code>
<Detail>The specified resource description is invalid.
 TrackingId: <id>, 
 SystemTracker:*name of my service bus*:Topic:*name of my topic*, 
 Timestamp:2024-08-16T08:05:54
</Detail>
</Error>
@github-actions github-actions bot added customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Sep 3, 2024
@jeremymeng jeremymeng self-assigned this Sep 3, 2024
@jeremymeng jeremymeng added Client This issue points to a problem in the data-plane of the library. Service Bus and removed question The issue doesn't require a change to the product in order to be resolved. Most issues start as that customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. labels Sep 3, 2024
@jeremymeng
Copy link
Member

@CezaryBD thanks for reporting the issue! It may be related to this issue #4983

However, even if we had correct XML payload, this scenario wouldn't work in a secure environment either due to Azure Service Bus service not supporting CORS for the ATOM management API in browsers: #4983

@CezaryBD
Copy link
Author

CezaryBD commented Sep 5, 2024

Hi @jeremymeng, thanks for quick response. What is the workaround or proposed solution? Our project's functionality relies on this API's method.

@jeremymeng
Copy link
Member

Hi @jeremymeng, thanks for quick response. What is the workaround or proposed solution? Our project's functionality relies on this API's method.

The CORS issue need support from the service team. But since you were able to send requests that means you already have a way around it?

Do you have to run the service bus code in the browsers? One alternative is to have a NodeJS backend to do that.

@jeremymeng
Copy link
Member

@CezaryBD there's an untested and unsupported way to switch to use fast-xml-parser. It will increase the bundle size of your app.

cat '.\patches@azure+core-xml+1.4.3.patch'

diff --git a/node_modules/@azure/core-xml/dist/browser/index.js b/node_modules/@azure/core-xml/dist/browser/index.js
index e3caeef..595f7fb 100644
--- a/node_modules/@azure/core-xml/dist/browser/index.js
+++ b/node_modules/@azure/core-xml/dist/browser/index.js
@@ -1,5 +1,5 @@
 // Copyright (c) Microsoft Corporation.
 // Licensed under the MIT license.
-export { stringifyXML, parseXML } from "./xml.js";
+export { stringifyXML, parseXML } from "../esm/xml.js";
 export { XML_ATTRKEY, XML_CHARKEY } from "./xml.common.js";
 //# sourceMappingURL=index.js.map
\ No newline at end of file```

@CezaryBD
Copy link
Author

CezaryBD commented Sep 6, 2024

I currently have no CORS issues whatsoever, but I do have issues that e.g. in the Microsoft Edge the payload generated looks like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<entry
    xmlns="http://www.w3.org/2005/Atom">
    <updated>2024-09-03T06:39:22.891Z</updated>
    <content type="application/xml">
        <SubscriptionDescription
            xmlns="http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"
            xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
            <AutoDeleteOnIdle>PT1H</AutoDeleteOnIdle>
        </SubscriptionDescription>
    </content>
</entry>

whereas generated for Firefox looks like in the original ticket.

Will there be a tested and supported way or do you completely stop supporting browsers?

Yes, I need to run Service Bus subscription creation code on our browser side, this is a critical part of our project's architecture. If I move it to our backend, what's the point of existence for this library?

@jeremymeng
Copy link
Member

If I move it to our backend, what's the point of existence for this library?

This package supports both browsers and NodeJS.

I'd thought I linked to this above but apparently, I linked to the same issue twice... Yes, this is a bug on only FireFox. We will look into it. #11655

jeremymeng added a commit that referenced this issue Sep 11, 2024
…31021)

Chrome-based browsers are more error-tolerant when the XML
namespace ("xmlns:...") was set via attribute, but that doesn't work on
Firefox,
which requires using of `createElementNS()` to create element with XML
namespace.

This PR adds special handling of the "xmlns" attribute.

-------

### Packages impacted by this PR
@azure/core-xml

### Issues associated with this PR
#11655
#30979
@jeremymeng
Copy link
Member

This has been fixed in @azure/core-xml 1.4.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Azure.Core Client This issue points to a problem in the data-plane of the library. Service Bus
Projects
None yet
Development

No branches or pull requests

2 participants