Skip to content

Commit 9e35bd4

Browse files
committed
fix: address Copilot review — handle encode errors, fix pool race, use curl -fS
- Handle json.NewEncoder errors in all handlers - Protect pool with sync.RWMutex to prevent data race during /evict - Extract newPool() helper to eliminate config duplication - Use r.Context() for new pool creation in /evict - Use curl -fSs in test.sh to fail on HTTP errors - Improve log.Fatal messages with actionable hints Signed-off-by: slayerjain <shubhamkjain@outlook.com>
1 parent db5caaf commit 9e35bd4

6 files changed

Lines changed: 369 additions & 82 deletions

File tree

ps-cache-postgres/keploy-logs.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
🐰 Keploy: 2026-04-16T22:44:46.289866404+05:30 INFO Generated config file based on the flags that are used
2+
🐰 Keploy: 2026-04-16T22:44:47.293693135+05:30 INFO Keploy agent is ready to record test cases and mocks.
3+
🐰 Keploy: 2026-04-16T22:44:47.293768075+05:30 INFO Starting Application : {"executing_cmd": "/usr/bin/sh -c ./server"}

ps-cache-postgres/keploy.yml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# Generated by Keploy (3-dev)
2+
path: ""
3+
appName: ps-cache-postgres
4+
appId: 0
5+
command: ./server
6+
templatize:
7+
testSets: []
8+
port: 0
9+
e2e: false
10+
dnsPort: 26789
11+
proxyPort: 16789
12+
incomingProxyPort: 36789
13+
debug: false
14+
disableTele: false
15+
disableANSI: false
16+
containerName: ""
17+
networkName: ""
18+
buildDelay: 30
19+
test:
20+
selectedTests: {}
21+
globalNoise:
22+
global: {}
23+
test-sets: {}
24+
replaceWith:
25+
global:
26+
url: {}
27+
port: {}
28+
test-sets: {}
29+
delay: 5
30+
host: localhost
31+
port: 0
32+
grpcPort: 0
33+
ssePort: 0
34+
protocol:
35+
grpc:
36+
port: 0
37+
http:
38+
port: 0
39+
sse:
40+
port: 0
41+
apiTimeout: 5
42+
skipCoverage: false
43+
coverageReportPath: ""
44+
ignoreOrdering: true
45+
mongoPassword: default@123
46+
language: ""
47+
removeUnusedMocks: false
48+
preserveFailedMocks: false
49+
fallBackOnMiss: false
50+
jacocoAgentPath: ""
51+
basePath: ""
52+
mocking: true
53+
ignoredTests: {}
54+
disableLineCoverage: false
55+
disableMockUpload: true
56+
useLocalMock: false
57+
updateTemplate: false
58+
mustPass: false
59+
maxFailAttempts: 5
60+
maxFlakyChecks: 1
61+
protoFile: ""
62+
protoDir: ""
63+
protoInclude: []
64+
compareAll: false
65+
schemaMatch: false
66+
updateTestMapping: false
67+
disableAutoHeaderNoise: false
68+
record:
69+
filters: []
70+
basePath: ""
71+
recordTimer: 0s
72+
metadata: ""
73+
sync: false
74+
enableSampling: 0
75+
memoryLimit: 0
76+
globalPassthrough: false
77+
tlsPrivateKeyPath: ""
78+
report:
79+
selectedTestSets: {}
80+
showFullBody: false
81+
reportPath: ""
82+
summary: false
83+
testCaseIDs: []
84+
format: ""
85+
disableMapping: true
86+
retryPassing: false
87+
configPath: ""
88+
bypassRules: []
89+
generateGithubActions: false
90+
keployContainer: keploy-v3
91+
keployNetwork: keploy-network
92+
cmdType: native
93+
contract:
94+
services: []
95+
tests: []
96+
path: ""
97+
download: false
98+
generate: false
99+
driven: consumer
100+
mappings:
101+
servicesMapping: {}
102+
self: s1
103+
inCi: false
104+
serverPort: 0
105+
mockDownload:
106+
registryIds: []
107+
108+
# Visit [https://keploy.io/docs/running-keploy/configuration-file/] to learn about using keploy through configration file.
Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
# Generated by Keploy (3-dev)
2+
version: api.keploy.io/v1beta1
3+
kind: PostgresV2
4+
name: mock-0
5+
spec:
6+
metadata:
7+
connID: "0"
8+
type: config
9+
requests:
10+
- message:
11+
packets:
12+
- header:
13+
header:
14+
payload_length: 35
15+
packet_id: ""
16+
packet_type: StartupMessage
17+
message:
18+
protocol_version: 196608
19+
parameters:
20+
database: demodb
21+
user: postgres
22+
- message:
23+
packets:
24+
- header:
25+
header:
26+
payload_length: 50
27+
packet_id: p
28+
packet_type: PasswordMessage
29+
message: cAAAADZTQ1JBTS1TSEEtMjU2AAAAACBuLCxuPSxyPWp5WW1jdUw3NkFPK1ZzM3U4T2dDenRjLw==
30+
- message:
31+
packets:
32+
- header:
33+
header:
34+
payload_length: 104
35+
packet_id: p
36+
packet_type: PasswordMessage
37+
message: cAAAAGxjPWJpd3Mscj1qeVltY3VMNzZBTytWczN1OE9nQ3p0Yy9rWFVpYTlJNFo2NWVLbHo2c2NLRUJNUzgscD1PWFFMcThadmZNLzFlaUx1N0oyZGFKdWlrMUlKM1JvUnNoN1lSSWFZNnlnPQ==
38+
responses:
39+
- message:
40+
packets:
41+
- header:
42+
header:
43+
payload_length: 19
44+
packet_id: R
45+
packet_type: AuthenticationSASL
46+
message:
47+
auth_mechanisms:
48+
- SCRAM-SHA-256
49+
- message:
50+
packets:
51+
- header:
52+
header:
53+
payload_length: 88
54+
packet_id: R
55+
packet_type: AuthenticationSASLContinue
56+
message:
57+
data: !!binary cj1qeVltY3VMNzZBTytWczN1OE9nQ3p0Yy9rWFVpYTlJNFo2NWVLbHo2c2NLRUJNUzgscz1LTXd2djZGQ21wUU5vYjJnOWd3djlBPT0saT00MDk2
58+
- message:
59+
packets:
60+
- header:
61+
header:
62+
payload_length: 50
63+
packet_id: R
64+
packet_type: AuthenticationSASLFinal
65+
message:
66+
data: !!binary dj1kK2NZNVhXdnJhRElPQVYwTFIrZXpzTU1TM3FYRjF6QzFMd3lzUHliS0pvPQ==
67+
- header:
68+
header:
69+
payload_length: 4
70+
packet_id: R
71+
packet_type: AuthenticationOk
72+
message: {}
73+
- header:
74+
header:
75+
payload_length: 19
76+
packet_id: S
77+
packet_type: ParameterStatus
78+
message:
79+
name: in_hot_standby
80+
value: "off"
81+
- header:
82+
header:
83+
payload_length: 21
84+
packet_id: S
85+
packet_type: ParameterStatus
86+
message:
87+
name: integer_datetimes
88+
value: "on"
89+
- header:
90+
header:
91+
payload_length: 17
92+
packet_id: S
93+
packet_type: ParameterStatus
94+
message:
95+
name: TimeZone
96+
value: Etc/UTC
97+
- header:
98+
header:
99+
payload_length: 23
100+
packet_id: S
101+
packet_type: ParameterStatus
102+
message:
103+
name: IntervalStyle
104+
value: postgres
105+
- header:
106+
header:
107+
payload_length: 16
108+
packet_id: S
109+
packet_type: ParameterStatus
110+
message:
111+
name: is_superuser
112+
value: "on"
113+
- header:
114+
header:
115+
payload_length: 18
116+
packet_id: S
117+
packet_type: ParameterStatus
118+
message:
119+
name: application_name
120+
value: ""
121+
- header:
122+
header:
123+
payload_length: 34
124+
packet_id: S
125+
packet_type: ParameterStatus
126+
message:
127+
name: default_transaction_read_only
128+
value: "off"
129+
- header:
130+
header:
131+
payload_length: 22
132+
packet_id: S
133+
packet_type: ParameterStatus
134+
message:
135+
name: scram_iterations
136+
value: "4096"
137+
- header:
138+
header:
139+
payload_length: 19
140+
packet_id: S
141+
packet_type: ParameterStatus
142+
message:
143+
name: DateStyle
144+
value: ISO, MDY
145+
- header:
146+
header:
147+
payload_length: 31
148+
packet_id: S
149+
packet_type: ParameterStatus
150+
message:
151+
name: standard_conforming_strings
152+
value: "on"
153+
- header:
154+
header:
155+
payload_length: 31
156+
packet_id: S
157+
packet_type: ParameterStatus
158+
message:
159+
name: session_authorization
160+
value: postgres
161+
- header:
162+
header:
163+
payload_length: 21
164+
packet_id: S
165+
packet_type: ParameterStatus
166+
message:
167+
name: client_encoding
168+
value: UTF8
169+
- header:
170+
header:
171+
payload_length: 47
172+
packet_id: S
173+
packet_type: ParameterStatus
174+
message:
175+
name: server_version
176+
value: 16.13 (Debian 16.13-1.pgdg13+1)
177+
- header:
178+
header:
179+
payload_length: 21
180+
packet_id: S
181+
packet_type: ParameterStatus
182+
message:
183+
name: server_encoding
184+
value: UTF8
185+
- header:
186+
header:
187+
payload_length: 8
188+
packet_id: K
189+
packet_type: BackendKeyData
190+
message:
191+
process_id: 1978
192+
secret_key: 2500793170
193+
- header:
194+
header:
195+
payload_length: 1
196+
packet_id: Z
197+
packet_type: ReadyForQuery
198+
message:
199+
tx_status: 73
200+
reqtimestampmock: 2026-04-16T22:44:47.297585428+05:30
201+
restimestampmock: 2026-04-16T22:44:47.302233216+05:30
202+
connectionId: "0"

0 commit comments

Comments
 (0)