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

Topic selector in subscription API not working #706

Closed
MarkejN opened this issue Oct 20, 2022 · 4 comments
Closed

Topic selector in subscription API not working #706

MarkejN opened this issue Oct 20, 2022 · 4 comments
Labels
bug Something isn't working pinned The issue must not be marked as stale

Comments

@MarkejN
Copy link

MarkejN commented Oct 20, 2022

I'm playing aroung with the subscription API and I think that the topic selector is not working properly. Fetching the subscription API with a topic selector in

const resp = await fetch(new URL(subscriptionsTopic, hubURL), {
always returns an empty subscriptions array.

Can be reproduced here: https://demo-chat.mercure.rocks/

I have the same problem locally with mercure v0.14.1. I suspect that the encoded slash (%2F) is not working. Using topic selectors without slash works, but the result is not filtered. It is the same as calling /.well-known/mercure/subscriptions without a topic.

@dunglas dunglas added the pinned The issue must not be marked as stale label Oct 20, 2022
@frizquierdo
Copy link

I'm playing aroung with the subscription API and I think that the topic selector is not working properly. Fetching the subscription API with a topic selector in

const resp = await fetch(new URL(subscriptionsTopic, hubURL), {

always returns an empty subscriptions array.
Can be reproduced here: https://demo-chat.mercure.rocks/

I have the same problem locally with mercure v0.14.1. I suspect that the encoded slash (%2F) is not working. Using topic selectors without slash works, but the result is not filtered. It is the same as calling /.well-known/mercure/subscriptions without a topic.

Me too. With the same Mercure hub version out of Docker, SF 5.4.13.

@pedrocasado
Copy link

Using topic selectors without slash works, but the result is not filtered. It is the same as calling /.well-known/mercure/subscriptions without a topic.

There's something with the topic selector. Look at this example with 2 subscribers filtering with the "teste" topic which returns some other topics.

Response from: http://127.0.0.1:55009/.well-known/mercure/subscriptions

{
  "@context": "https://mercure.rocks/",
  "id": "/.well-known/mercure/subscriptions",
  "type": "Subscriptions",
  "lastEventID": "urn:uuid:fbf6a829-f040-48e0-9a4c-7de0f2054d09",
  "subscriptions": [
    {
      "id": "/.well-known/mercure/subscriptions/teste/urn%3Auuid%3Aa80e910f-5f52-444d-982e-a56715246c14",
      "type": "Subscription",
      "subscriber": "urn:uuid:a80e910f-5f52-444d-982e-a56715246c14",
      "topic": "teste",
      "active": true
    },
    {
      "id": "/.well-known/mercure/subscriptions/%2Fbooks%2F2/urn%3Auuid%3Aa80e910f-5f52-444d-982e-a56715246c14",
      "type": "Subscription",
      "subscriber": "urn:uuid:a80e910f-5f52-444d-982e-a56715246c14",
      "topic": "/books/2",
      "active": true
    },
    {
      "id": "/.well-known/mercure/subscriptions/%2Fconfig%2F1234/urn%3Auuid%3Aa80e910f-5f52-444d-982e-a56715246c14",
      "type": "Subscription",
      "subscriber": "urn:uuid:a80e910f-5f52-444d-982e-a56715246c14",
      "topic": "/config/1234",
      "active": true
    },
    {
      "id": "/.well-known/mercure/subscriptions/http%3A%2F%2F127.0.0.1%2F54bbb590-6a19-470f-a836-9dce7a3fc514/urn%3Auuid%3A495ea86d-dc94-472c-8fdb-ba22ac9d447e",
      "type": "Subscription",
      "subscriber": "urn:uuid:495ea86d-dc94-472c-8fdb-ba22ac9d447e",
      "topic": "http://127.0.0.1/54bbb590-6a19-470f-a836-9dce7a3fc514",
      "active": true,
      "payload": {
        "remoteAddr": "127.0.0.1",
        "user": "https://example.com/users/dunglas"
      }
    }
  ]
}

Response filtering the topic "teste" should not return other topics. http://127.0.0.1:55009/.well-known/mercure/subscriptions/teste:

{
  "@context": "https://mercure.rocks/",
  "id": "/.well-known/mercure/subscriptions/teste",
  "type": "Subscriptions",
  "lastEventID": "urn:uuid:deb3110f-d862-4c9c-accd-9493db72b0be",
  "subscriptions": [
    {
      "id": "/.well-known/mercure/subscriptions/teste/urn%3Auuid%3A4c70ca4e-64fa-49a7-bae5-49f00f80db25",
      "type": "Subscription",
      "subscriber": "urn:uuid:4c70ca4e-64fa-49a7-bae5-49f00f80db25",
      "topic": "teste",
      "active": true
    },
    {
      "id": "/.well-known/mercure/subscriptions/%2Fbooks%2F2/urn%3Auuid%3A4c70ca4e-64fa-49a7-bae5-49f00f80db25",
      "type": "Subscription",
      "subscriber": "urn:uuid:4c70ca4e-64fa-49a7-bae5-49f00f80db25",
      "topic": "/books/2",
      "active": true
    },
    {
      "id": "/.well-known/mercure/subscriptions/%2Fconfig%2F1234/urn%3Auuid%3A4c70ca4e-64fa-49a7-bae5-49f00f80db25",
      "type": "Subscription",
      "subscriber": "urn:uuid:4c70ca4e-64fa-49a7-bae5-49f00f80db25",
      "topic": "/config/1234",
      "active": true
    }
  ]
}

Mercure 0.14.5, SF 5.4

@itodor
Copy link
Contributor

itodor commented Nov 16, 2023

Here's my proposed fix: #834

@MarkejN
Copy link
Author

MarkejN commented Jan 15, 2025

Sorry for the late reply. I have tested it again with v0.18.1 and now it works. Thank you very much!

@MarkejN MarkejN closed this as completed Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pinned The issue must not be marked as stale
Projects
None yet
Development

No branches or pull requests

5 participants