Skip to content

Commit 58efc26

Browse files
taimoorzaeemsteve-chavez
authored andcommitted
fix: server-host !6 incorrectly binds to IPv4 address
Updates streaming-commons to version 0.2.3.1. This resolves #3202. Signed-off-by: Taimoor Zaeem <[email protected]>
1 parent 8180905 commit 58efc26

File tree

7 files changed

+32
-5
lines changed

7 files changed

+32
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file. From versio
77
## Fixed
88

99
- Fix `db-pre-config` function failing when function names are pg reserved words by @taimoorzaeem in #4380
10+
- Fix `server-host=!6` incorrectly binds to IPv4 address by @taimoorzaeem in #3202
1011

1112
## [14.0] - 2025-10-24
1213

cabal.project.freeze

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
index-state: hackage.haskell.org 2025-10-13T04:53:27Z
1+
index-state: hackage.haskell.org 2025-10-29T04:02:18Z

nix/overlays/haskell-packages.nix

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@ let
6060
}
6161
{ };
6262

63+
# TODO: Remove once available in nixpkgs haskellPackages
64+
streaming-commons =
65+
prev.callHackageDirect
66+
{
67+
pkg = "streaming-commons";
68+
ver = "0.2.3.1";
69+
sha256 = "sha256-Gl2eaJcWe1sxmcE/octWlH9uSnERguf+5H66K4fV87s=";
70+
}
71+
{ };
72+
6373
# Downgrade hasql and related packages while we are still on GHC 9.4 for the static build.
6474
hasql = lib.dontCheck (lib.doJailbreak prev.hasql_1_6_4_4);
6575
hasql-dynamic-statements = lib.dontCheck prev.hasql-dynamic-statements_0_3_1_5;

postgrest.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ library
139139
, regex-tdfa >= 1.2.2 && < 1.4
140140
, retry >= 0.7.4 && < 0.10
141141
, scientific >= 0.3.4 && < 0.4
142-
, streaming-commons >= 0.1.1 && < 0.3
142+
, streaming-commons >= 0.2.3.1 && < 0.3
143143
, swagger2 >= 2.4 && < 2.9
144144
, text >= 1.2.2 && < 2.2
145145
, time >= 1.6 && < 1.13

stack.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ extra-deps:
1414
- hasql-pool-1.0.1
1515
- jose-jwt-0.10.0
1616
- postgresql-libpq-0.10.1.0
17+
- streaming-commons-0.2.3.1

stack.yaml.lock

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ packages:
3939
size: 1096
4040
original:
4141
hackage: postgresql-libpq-0.10.1.0
42+
- completed:
43+
hackage: streaming-commons-0.2.3.1@sha256:ed7999fea9e912b1211ea93d7e20a7998bf4753166370c94048885650f303bf0,4841
44+
pantry-tree:
45+
sha256: f08e83fb00fd45865fa8cfdef5ecef7161d5135257ee98050bfbe4b807ad65f8
46+
size: 2374
47+
original:
48+
hackage: streaming-commons-0.2.3.1
4249
snapshots:
4350
- completed:
4451
sha256: 238fa745b64f91184f9aa518fe04bdde6552533d169b0da5256670df83a0f1a9

test/io/postgrest.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,19 @@ def run(
9494
"Run PostgREST and yield an endpoint that is ready for connections."
9595

9696
with tempfile.TemporaryDirectory() as tmpdir:
97+
98+
# with python requests, "localhost" doesn't automatically resolves
99+
# to [::1], hence we use this explicitly when host is ipv6 special
100+
# address
101+
ipv6_special_addresses = ["*6", "!6"]
102+
103+
localhost = "[::1]" if host in ipv6_special_addresses else "localhost"
104+
97105
if port:
98106
env["PGRST_SERVER_PORT"] = str(port)
99-
env["PGRST_SERVER_HOST"] = host or "localhost"
107+
env["PGRST_SERVER_HOST"] = host or localhost
100108
# When constructing IPv6 address, host address should be bracketed like [host]
101-
apihost = f"[{host}]" if host and is_ipv6(host) else "localhost"
109+
apihost = f"[{host}]" if host and is_ipv6(host) else localhost
102110
baseurl = f"http://{apihost}:{port}"
103111
else:
104112
socketfile = pathlib.Path(tmpdir) / "postgrest.sock"
@@ -107,7 +115,7 @@ def run(
107115

108116
adminport = freeport(port)
109117
env["PGRST_ADMIN_SERVER_PORT"] = str(adminport)
110-
adminhost = f"[{host}]" if host and is_ipv6(host) else "localhost"
118+
adminhost = f"[{host}]" if host and is_ipv6(host) else localhost
111119
adminurl = f"http://{adminhost}:{adminport}"
112120

113121
command = [POSTGREST_BIN]

0 commit comments

Comments
 (0)