Conversation
✅ Deploy Preview for zio-http ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Pull request overview
Aligns the Scala Datastar SDK with the Datastar JS client behavior by reading GET request signals from the datastar query parameter (instead of a request header), and updates the associated test suite accordingly.
Changes:
- Updated
readSignalsGET handling to readdatastarfromrequest.queryParam("datastar"). - Updated GET-path tests to pass
datastarvia query parameters and renamed tests to reflect this. - Kept non-GET behavior reading signals from the request body.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
zio-http-datastar-sdk/src/main/scala/zio/http/datastar/DatastarPackageBase.scala |
Switches GET signal extraction from header to query param. |
zio-http-datastar-sdk/src/test/scala/zio/http/datastar/ReadSignalsSpec.scala |
Migrates GET tests to query-param based requests and updates test names. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+29
to
+32
| test("should read signals from datastar query parameter with simple data") { | ||
| val jsonData = """{\"{count\"":42}""" | ||
| val request = Request | ||
| .get(URL.root / "test") | ||
| .addHeader(Header.Custom("datastar", jsonData)) | ||
| .get((URL.root / "test").addQueryParams(QueryParams("datastar" -> jsonData))) |
Comment on lines
+40
to
+43
| test("should read signals from datastar query parameter with complex data") { | ||
| val jsonData = """{"{name":"John Doe","age":30,"email":"john@example.com"}""" | ||
| val request = Request | ||
| .get(URL.root / "test") | ||
| .addHeader(Header.Custom("datastar", jsonData)) | ||
| .get((URL.root / "test").addQueryParams(QueryParams("datastar" -> jsonData))) |
Comment on lines
+53
to
+56
| test("should read signals from datastar query parameter with nested data") { | ||
| val jsonData = """{"{user":{"name":"Jane","age":25,"email":"jane@test.com"},"active":true}""" | ||
| val request = Request | ||
| .get(URL.root / "test") | ||
| .addHeader(Header.Custom("datastar", jsonData)) | ||
| .get((URL.root / "test").addQueryParams(QueryParams("datastar" -> jsonData))) |
| }, | ||
| test("should fail when JSON doesn't match schema") { | ||
| val jsonData = """{"wrong":"field"}""" | ||
| val jsonData = """{"{wrong":"field"}""" |
73c788c to
299ece9
Compare
299ece9 to
a4a8c55
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Datastar JS SDK sends signals as a
datastarquery parameter for GET requests, not as a header. This fix updates the Scala SDK to correctly read signals from the query parameter for GET requests, addressing the inconsistency.Changes
readSignalsto userequest.queryParam("datastar")for GET requests instead ofrequest.header[String]("datastar")Fixes #4020