Skip to content

Commit 6e291f5

Browse files
committed
fix: remove user-provided token header when injecting GCS idempotency token to prevent conflicts
1 parent 8169924 commit 6e291f5

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

handwritten/storage/src/nodejs-common/service.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,9 @@ export class Service {
286286
}-${getModuleFormat()} gccl-invocation-id/${idempotencyToken}`,
287287
};
288288
if (!hasValidUserToken) {
289+
if (userTokenKey) {
290+
delete reqOpts.headers[userTokenKey];
291+
}
289292
reqOpts.headers['x-goog-gcs-idempotency-token'] = idempotencyToken;
290293
}
291294

handwritten/storage/src/resumable-upload.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,9 @@ export class Upload extends Writable {
847847
};
848848

849849
if (!hasValidUserToken) {
850+
if (userTokenKey) {
851+
delete reqOpts.headers![userTokenKey];
852+
}
850853
reqOpts.headers!['x-goog-gcs-idempotency-token'] = this.currentInvocationId.uri;
851854
}
852855

@@ -1037,6 +1040,9 @@ export class Upload extends Writable {
10371040
};
10381041

10391042
if (!hasValidUserToken) {
1043+
if (userTokenKey) {
1044+
delete headers[userTokenKey];
1045+
}
10401046
headers['x-goog-gcs-idempotency-token'] = this.currentInvocationId.chunk;
10411047
}
10421048

@@ -1270,6 +1276,9 @@ export class Upload extends Writable {
12701276
};
12711277

12721278
if (!hasValidUserToken) {
1279+
if (userTokenKey) {
1280+
delete opts.headers![userTokenKey];
1281+
}
12731282
opts.headers!['x-goog-gcs-idempotency-token'] = this.currentInvocationId.checkUploadStatus;
12741283
}
12751284

0 commit comments

Comments
 (0)