Skip to content

Commit ea36231

Browse files
authored
fix: redis/fastapi-cache2 compatibility and vault test typo (#63)
* fix: redis/fastapi-cache2 compatibility and vault test typo - Pin redis to 4.6.0 (latest 4.x) for fastapi-cache2 compatibility - fastapi-cache2 0.2.2 requires redis>=4.2.0rc1,<5.0.0 - redis 4.3.0+ required for redis.asyncio.cluster module - Fix CacheManager to not use decode_responses=True - fastapi-cache2 stores binary data, requires decode_responses=False - Fix typo in vault test: $PROJECT_RO../devstack -> $PROJECT_ROOT/devstack All 17 test suites (571+ tests) pass. * fix: update go.mod/go.sum for prometheus dependency go mod tidy to fix missing go.sum entries for prometheus packages.
1 parent cc95f7d commit ea36231

7 files changed

Lines changed: 30 additions & 15 deletions

File tree

reference-apps/fastapi-api-first/app/middleware/cache.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,9 @@ async def init(self, redis_url: str, prefix: str = "cache:"):
166166
prefix: Cache key prefix
167167
"""
168168
try:
169-
self.redis_client = aioredis.from_url(
170-
redis_url,
171-
encoding="utf8",
172-
decode_responses=True
173-
)
169+
# Note: decode_responses must be False (default) for fastapi-cache2
170+
# as it stores cached data as binary/bytes
171+
self.redis_client = aioredis.from_url(redis_url)
174172

175173
# Test connection
176174
await self.redis_client.ping()

reference-apps/fastapi-api-first/requirements.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ motor==3.7.1
1919
pymongo==4.15.5
2020

2121
# Redis and Caching
22-
redis[hiredis]==7.1.0 # Compatible with fastapi-cache2 (requires <5.0.0)
22+
# redis 4.3.0+ required for redis.asyncio.cluster module used by fastapi-cache2
23+
# redis 4.6.0 is the latest 4.x version compatible with fastapi-cache2 (<5.0.0 requirement)
24+
redis[hiredis]==4.6.0 # fastapi-cache2 0.2.2 requires redis>=4.2.0rc1,<5.0.0
2325
fastapi-cache2[redis]==0.2.2 # Response caching
2426

2527
# RabbitMQ

reference-apps/fastapi/app/middleware/cache.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,9 @@ async def init(self, redis_url: str, prefix: str = "cache:"):
166166
prefix: Cache key prefix
167167
"""
168168
try:
169-
self.redis_client = aioredis.from_url(
170-
redis_url,
171-
encoding="utf8",
172-
decode_responses=True
173-
)
169+
# Note: decode_responses must be False (default) for fastapi-cache2
170+
# as it stores cached data as binary/bytes
171+
self.redis_client = aioredis.from_url(redis_url)
174172

175173
# Test connection
176174
await self.redis_client.ping()

reference-apps/fastapi/requirements.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ motor==3.7.1
1515
pymongo==4.15.5
1616

1717
# Redis and Caching
18-
redis[hiredis]==7.1.0 # fastapi-cache2 0.2.2 requires redis<5.0.0
18+
# redis 4.3.0+ required for redis.asyncio.cluster module used by fastapi-cache2
19+
# redis 4.6.0 is the latest 4.x version compatible with fastapi-cache2 (<5.0.0 requirement)
20+
redis[hiredis]==4.6.0 # fastapi-cache2 0.2.2 requires redis>=4.2.0rc1,<5.0.0
1921
fastapi-cache2[redis]==0.2.2 # Response caching
2022

2123
# RabbitMQ

reference-apps/golang/go.mod

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ require (
88
github.com/google/uuid v1.6.0
99
github.com/hashicorp/vault/api v1.22.0
1010
github.com/jackc/pgx/v5 v5.7.6
11+
github.com/prometheus/client_golang v1.19.1
1112
github.com/rabbitmq/amqp091-go v1.10.0
1213
github.com/redis/go-redis/v9 v9.17.2
1314
github.com/sirupsen/logrus v1.9.3
@@ -16,6 +17,7 @@ require (
1617

1718
require (
1819
filippo.io/edwards25519 v1.1.0 // indirect
20+
github.com/beorn7/perks v1.0.1 // indirect
1921
github.com/bytedance/sonic v1.14.0 // indirect
2022
github.com/bytedance/sonic/loader v0.3.0 // indirect
2123
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
@@ -53,6 +55,9 @@ require (
5355
github.com/modern-go/reflect2 v1.0.2 // indirect
5456
github.com/montanaflynn/stats v0.7.1 // indirect
5557
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
58+
github.com/prometheus/client_model v0.5.0 // indirect
59+
github.com/prometheus/common v0.48.0 // indirect
60+
github.com/prometheus/procfs v0.12.0 // indirect
5661
github.com/quic-go/qpack v0.5.1 // indirect
5762
github.com/quic-go/quic-go v0.54.1 // indirect
5863
github.com/ryanuber/go-glob v1.0.0 // indirect

reference-apps/golang/go.sum

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
22
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
3+
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
4+
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
35
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
46
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
57
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
@@ -110,6 +112,14 @@ github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0
110112
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
111113
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
112114
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
115+
github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE=
116+
github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho=
117+
github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw=
118+
github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI=
119+
github.com/prometheus/common v0.48.0 h1:QO8U2CdOzSn1BBsmXJXduaaW+dY/5QLjfB8svtSzKKE=
120+
github.com/prometheus/common v0.48.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc=
121+
github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo=
122+
github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo=
113123
github.com/quic-go/qpack v0.5.1 h1:giqksBPnT/HDtZ6VhtFKgoLOWmlyo9Ei6u9PqzIMbhI=
114124
github.com/quic-go/qpack v0.5.1/go.mod h1:+PC4XFrEskIVkcLzpEkbLqq1uCoxPhQuvK5rH1ZgaEg=
115125
github.com/quic-go/quic-go v0.54.1 h1:4ZAWm0AhCb6+hE+l5Q1NAL0iRn/ZrMwqHRGQiFwj2eg=

tests/test-vault.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -567,13 +567,13 @@ test_management_commands() {
567567
info "Test 10: Management script Vault commands work"
568568

569569
# Test vault-status
570-
if "$PROJECT_RO../devstack" vault-status &>/dev/null; then
570+
if "$PROJECT_ROOT/devstack" vault-status &>/dev/null; then
571571
# Test vault-token
572-
local token=$("$PROJECT_RO../devstack" vault-token 2>/dev/null)
572+
local token=$("$PROJECT_ROOT/devstack" vault-token 2>/dev/null)
573573

574574
if [ -n "$token" ]; then
575575
# Test vault-show-password
576-
local password=$("$PROJECT_RO../devstack" vault-show-password postgres 2>/dev/null)
576+
local password=$("$PROJECT_ROOT/devstack" vault-show-password postgres 2>/dev/null)
577577

578578
if [ -n "$password" ]; then
579579
success "Management commands work correctly"

0 commit comments

Comments
 (0)