Skip to content

Commit f3d0bfc

Browse files
chore: validation for package metadata and _rev field (#1839)
This pr adds code to throw explicit errors when metadata is missing or lacks the required _rev field during package replication checks. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --------- Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent be54fb6 commit f3d0bfc

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

src/__tests__/__snapshots__/construct-hub.test.ts.snap

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/__tests__/devapp/__snapshots__/snapshot.test.ts.snap

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/package-sources/npmjs/couch-changes.lambda-shared.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ export class CouchChanges extends EventEmitter {
110110
while(Date.now() - startTime < MAX_PACKAGE_SERVER_LAG_MS) {
111111
try {
112112
const meta = await this.https('get', metadataUrl);
113+
if (!meta) {
114+
throw new Error(`No metadata for ${change.id}`);
115+
}
116+
if (!meta._rev) {
117+
throw new Error(`No _rev in metadata for ${change.id}`);
118+
}
113119
const latestReplicaRev = parseSequentialRevision(meta._rev as string);
114120

115121
change.doc = meta; // add metadata to the change object

0 commit comments

Comments
 (0)