generator icon indicating copy to clipboard operation
generator copied to clipboard

Dart WebSocket client template doesn't support query parameters from channel bindings

Open batchu5 opened this issue 9 months ago • 11 comments

The Dart WebSocket client template doesn't extract or use query parameters defined in channel bindings, unlike the Python template. This prevents authentication tokens and other important parameters from being passed to WebSocket connections.

When a channel defines query parameters in its bindings (e.g., auth_token for authentication), the generated JavaScript client should:

  1. Accept these parameters in the constructor
  2. Automatically append them to the WebSocket URL as query strings
// Expected generated code
ExampleClient({String? url, String? auth_token})
  : _url = _buildUrl(url ?? 'wss://default-url', auth_token);

static String _buildUrl(String baseUrl, String? authToken) {
  if (authToken == null) return baseUrl;
  return '$baseUrl?auth_token=$authToken';
}

batchu5 avatar Feb 09 '26 10:02 batchu5

You're right—the Dart WebSocket client template does not currently extract or use query parameters from channel bindings, so parameters like auth_token can't be passed as part of the WebSocket URL. This is a known limitation and contrasts with the Python template, which uses a shared helper (getQueryParams) to extract query parameters and append them to the URL in the generated client constructor (source).

To bring the Dart template in line with the Python template, you would need to:

  • Use the getQueryParams helper to extract query parameters from channel bindings.
  • Update the generated Dart client constructor to accept these parameters as arguments.
  • Build a query string from the provided arguments and append it to the WebSocket URL before connecting.

The Python template provides a clear model for this: it exposes query parameters as constructor arguments, assembles them into a query string, and appends them to the URL if present (example). The Dart template would need similar logic added to its constructor and connection setup (current Dart constructor).

Recent work on shared WebSocket client template components (see PR #1728) introduced query parameter variables, which could be reused to keep the implementation consistent across languages (source).

In summary: the Dart template does not yet support this, but the path forward is clear—mirror the Python template's approach using the shared helpers and update the constructor and URL assembly logic accordingly.

To reply, just mention @dosu.


Docs are dead. Just use Dosu.

Leave Feedback Ask Dosu about generator Share Dosu with your team

dosubot[bot] avatar Feb 09 '26 10:02 dosubot[bot]

@Adi-204, please take a look at this!

batchu5 avatar Feb 10 '26 01:02 batchu5

@batchu5 you can work on issue or if you are not interest please do update issue description and add it is open for contribution.

Adi-204 avatar Mar 16 '26 15:03 Adi-204

yep, I'm interested, will raise a PR soon.

batchu5 avatar Mar 16 '26 16:03 batchu5

@batchu5 are you working on it ? If not ,I can take this one.

SHUBHANSHU602 avatar Jun 21 '26 13:06 SHUBHANSHU602

@SHUBHANSHU602, you can work on it :)

batchu5 avatar Jun 21 '26 15:06 batchu5

Thanks !

SHUBHANSHU602 avatar Jun 21 '26 17:06 SHUBHANSHU602

I'm working on this!

batchu5 avatar Jun 28 '26 03:06 batchu5

sure @batchu5 !

SHUBHANSHU602 avatar Jun 28 '26 04:06 SHUBHANSHU602

still working @batchu5 ?

SHUBHANSHU602 avatar Aug 26 '26 17:08 SHUBHANSHU602

@batchu5 If you're not working on this can i take it?

devxdh avatar Oct 29 '26 17:10 devxdh