Skip to content

Commit a9e169b

Browse files
handle empty nodes, chunk eval requests (#2556)
1 parent 0a6d827 commit a9e169b

File tree

10 files changed

+22
-15
lines changed

10 files changed

+22
-15
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "openapi-workspaces",
33
"license": "MIT",
44
"private": true,
5-
"version": "0.53.3",
5+
"version": "0.53.4",
66
"workspaces": [
77
"projects/json-pointer-helpers",
88
"projects/openapi-io",

projects/fastify-capture/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@useoptic/fastify-capture",
33
"license": "MIT",
44
"packageManager": "[email protected]",
5-
"version": "0.53.3",
5+
"version": "0.53.4",
66
"main": "build/index.js",
77
"types": "build/index.d.ts",
88
"files": [

projects/json-pointer-helpers/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@useoptic/json-pointer-helpers",
33
"license": "MIT",
44
"packageManager": "[email protected]",
5-
"version": "0.53.3",
5+
"version": "0.53.4",
66
"main": "build/index.js",
77
"types": "build/index.d.ts",
88
"files": [

projects/openapi-io/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@useoptic/openapi-io",
33
"license": "MIT",
44
"packageManager": "[email protected]",
5-
"version": "0.53.3",
5+
"version": "0.53.4",
66
"main": "build/index.js",
77
"types": "build/index.d.ts",
88
"files": [

projects/openapi-utilities/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@useoptic/openapi-utilities",
33
"license": "MIT",
44
"packageManager": "[email protected]",
5-
"version": "0.53.3",
5+
"version": "0.53.4",
66
"main": "build/index.js",
77
"types": "build/index.d.ts",
88
"files": [

projects/optic/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@useoptic/optic",
33
"license": "MIT",
44
"packageManager": "[email protected]",
5-
"version": "0.53.3",
5+
"version": "0.53.4",
66
"main": "build/index.js",
77
"types": "build/index.d.ts",
88
"files": [

projects/rulesets-base/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@useoptic/rulesets-base",
33
"license": "MIT",
44
"packageManager": "[email protected]",
5-
"version": "0.53.3",
5+
"version": "0.53.4",
66
"main": "build/index.js",
77
"types": "build/index.d.ts",
88
"files": [

projects/standard-rulesets/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@useoptic/standard-rulesets",
33
"license": "MIT",
44
"packageManager": "[email protected]",
5-
"version": "0.53.3",
5+
"version": "0.53.4",
66
"main": "build/index.js",
77
"types": "build/index.d.ts",
88
"files": [

projects/standard-rulesets/src/lintgpt/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ export class LintGpt extends ExternalRuleBase {
233233
const eval_data = {
234234
rule_checksum,
235235
location_context: operation.locationContext,
236-
node: stableStringify(operation.value),
236+
node: stableStringify(operation.value ?? ''),
237237
node_before: stableStringify(operation.before ?? ''),
238238
};
239239
const node_checksum = computeNodeChecksum(eval_data);
@@ -249,7 +249,7 @@ export class LintGpt extends ExternalRuleBase {
249249
const eval_data = {
250250
rule_checksum,
251251
location_context: response.locationContext,
252-
node: stableStringify(response.value),
252+
node: stableStringify(response.value ?? ''),
253253
node_before: stableStringify(response.before ?? ''),
254254
};
255255
const node_checksum = computeNodeChecksum(eval_data);
@@ -265,7 +265,7 @@ export class LintGpt extends ExternalRuleBase {
265265
const eval_data = {
266266
rule_checksum,
267267
location_context: property.locationContext,
268-
node: stableStringify(property.value),
268+
node: stableStringify(property.value ?? ''),
269269
node_before: stableStringify(property.before ?? ''),
270270
};
271271
const node_checksum = computeNodeChecksum(eval_data);

projects/standard-rulesets/src/lintgpt/rules-helper.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,12 @@ export class LintgptRulesHelper {
260260
const evalsToRequest = requestsWithoutEvals.map(
261261
(r) => r.eval_request
262262
);
263-
await this.client.requestLintgptEvals(evalsToRequest);
263+
const evalsToRequestChunks = chunk(evalsToRequest, 20);
264+
for (const chunk of evalsToRequestChunks) {
265+
await this.client.requestLintgptEvals(chunk);
266+
await new Promise((resolve) => setTimeout(resolve, 20));
267+
}
264268
}
265-
266269
firstRun = false;
267270
}
268271

@@ -288,7 +291,11 @@ export class LintgptRulesHelper {
288291
}
289292

290293
export const computeRuleChecksum = (rule: string): string =>
291-
crypto.createHash('sha256').update(rule).digest('base64').toString();
294+
crypto
295+
.createHash('sha256')
296+
.update(rule ?? '')
297+
.digest('base64')
298+
.toString();
292299

293300
export const computeNodeChecksum = ({
294301
node,
@@ -302,7 +309,7 @@ export const computeNodeChecksum = ({
302309
crypto
303310
.createHash('sha256')
304311
.update(location_context)
305-
.update(node)
312+
.update(node ?? '')
306313
.update(node_before ?? '')
307314
.digest('base64')
308315
.toString();

0 commit comments

Comments
 (0)