Skip to content

Commit b8020b2

Browse files
committed
fix(openfeature): trim accepted ETags
1 parent 053684d commit b8020b2

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

packages/dd-trace/src/openfeature/agentless_configuration_source.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,8 @@ class AgentlessConfigurationSource {
234234
return { rejected: true, applicationFailed: true }
235235
}
236236

237-
this._etag = response.etag?.trim() ? response.etag : undefined
237+
const etag = response.etag?.trim()
238+
this._etag = etag || undefined
238239
return { applied: true }
239240
}
240241

packages/dd-trace/test/openfeature/agentless_configuration_source.spec.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,26 @@ describe('AgentlessConfigurationSource', () => {
123123
assert.strictEqual(requests[0].options.redirect, 'manual')
124124
})
125125

126+
it('trims an accepted ETag before reusing it', async () => {
127+
const paddedEtagFetch = sinon.stub()
128+
paddedEtagFetch.onFirstCall().resolves({
129+
status: 200,
130+
headers: { get: name => name === 'etag' ? ' W/"ufc-v1" ' : null },
131+
text: () => Promise.resolve(VALID_RESPONSE),
132+
})
133+
paddedEtagFetch.onSecondCall().resolves({
134+
status: 304,
135+
headers: new Headers(),
136+
})
137+
const configurationSource = source({ fetch: paddedEtagFetch })
138+
139+
await poll(configurationSource)
140+
await poll(configurationSource)
141+
142+
assert.strictEqual(paddedEtagFetch.secondCall.args[1].headers['If-None-Match'], 'W/"ufc-v1"')
143+
sinon.assert.calledOnceWithExactly(applyConfiguration, JSON.parse(VALID_UFC))
144+
})
145+
126146
it('suppresses tracing around agentless requests', () => {
127147
responses.push({ statusCode: 200, body: VALID_RESPONSE })
128148

0 commit comments

Comments
 (0)