@constructive-io/graphql-server 5.28.6 → 5.28.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -41,6 +41,28 @@ const isGraphQLLayerError = (value) => value == null ||
41
41
  (value.name === 'GraphQLError' &&
42
42
  isGraphQLLayerError(value.originalError));
43
43
  const isRequestError = (error) => error.path == null && isGraphQLLayerError(error.originalError);
44
+ /**
45
+ * A request error's message without the values the request sent. graphql-js
46
+ * writes a variable coercion failure as `Variable "$x" got invalid value <the
47
+ * value> at "<path>"; <inner>`, and a leaf type's inner complaint ends in the
48
+ * value too (`String cannot represent a non string value: <value>`,
49
+ * `Value "<value>" does not exist in "E" enum.`), so a password or API key sent
50
+ * in a malformed input would come back in the answer. The variable, the path and
51
+ * what was wrong stay; the values go.
52
+ */
53
+ const withoutInputValues = (error) => {
54
+ const inner = error.originalError?.message;
55
+ const message = error.message;
56
+ if (!message.startsWith('Variable "$') || !inner || !message.endsWith(`; ${inner}`))
57
+ return message;
58
+ const prefix = message.slice(0, message.length - inner.length - 2);
59
+ const variable = /^Variable "\$[^"]+"/.exec(prefix)?.[0];
60
+ const at = / at "[^"]*"$/.exec(prefix)?.[0] ?? '';
61
+ const complaint = inner
62
+ .replace(/(value): [\s\S]*$/, '$1.')
63
+ .replace(/^Value "[\s\S]*" does not exist in/, 'Value does not exist in');
64
+ return `${variable} got invalid value${at}; ${complaint}`;
65
+ };
44
66
  /** The code a surfaced request error carries when graphql-js supplied none. */
45
67
  const BAD_USER_INPUT = 'BAD_USER_INPUT';
46
68
  /**
@@ -85,7 +107,7 @@ export const maskError = (error) => {
85
107
  if (!effectiveCode && isRequestError(error)) {
86
108
  extensions.code = BAD_USER_INPUT;
87
109
  return {
88
- message: error.message,
110
+ message: withoutInputValues(error),
89
111
  ...(error.locations ? { locations: error.locations } : {}),
90
112
  extensions,
91
113
  };
@@ -47,6 +47,28 @@ const isGraphQLLayerError = (value) => value == null ||
47
47
  (value.name === 'GraphQLError' &&
48
48
  isGraphQLLayerError(value.originalError));
49
49
  const isRequestError = (error) => error.path == null && isGraphQLLayerError(error.originalError);
50
+ /**
51
+ * A request error's message without the values the request sent. graphql-js
52
+ * writes a variable coercion failure as `Variable "$x" got invalid value <the
53
+ * value> at "<path>"; <inner>`, and a leaf type's inner complaint ends in the
54
+ * value too (`String cannot represent a non string value: <value>`,
55
+ * `Value "<value>" does not exist in "E" enum.`), so a password or API key sent
56
+ * in a malformed input would come back in the answer. The variable, the path and
57
+ * what was wrong stay; the values go.
58
+ */
59
+ const withoutInputValues = (error) => {
60
+ const inner = error.originalError?.message;
61
+ const message = error.message;
62
+ if (!message.startsWith('Variable "$') || !inner || !message.endsWith(`; ${inner}`))
63
+ return message;
64
+ const prefix = message.slice(0, message.length - inner.length - 2);
65
+ const variable = /^Variable "\$[^"]+"/.exec(prefix)?.[0];
66
+ const at = / at "[^"]*"$/.exec(prefix)?.[0] ?? '';
67
+ const complaint = inner
68
+ .replace(/(value): [\s\S]*$/, '$1.')
69
+ .replace(/^Value "[\s\S]*" does not exist in/, 'Value does not exist in');
70
+ return `${variable} got invalid value${at}; ${complaint}`;
71
+ };
50
72
  /** The code a surfaced request error carries when graphql-js supplied none. */
51
73
  const BAD_USER_INPUT = 'BAD_USER_INPUT';
52
74
  /**
@@ -92,7 +114,7 @@ const maskError = (error) => {
92
114
  if (!effectiveCode && isRequestError(error)) {
93
115
  extensions.code = BAD_USER_INPUT;
94
116
  return {
95
- message: error.message,
117
+ message: withoutInputValues(error),
96
118
  ...(error.locations ? { locations: error.locations } : {}),
97
119
  extensions,
98
120
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructive-io/graphql-server",
3
- "version": "5.28.6",
3
+ "version": "5.28.8",
4
4
  "author": "Constructive <developers@constructive.io>",
5
5
  "description": "Constructive GraphQL Server",
6
6
  "main": "index.js",
@@ -43,19 +43,19 @@
43
43
  "dependencies": {
44
44
  "@agentic-kit/ollama": "2.15.0",
45
45
  "@constructive-io/csrf": "^0.30.0",
46
- "@constructive-io/errors": "^0.21.0",
47
- "@constructive-io/express-context": "^0.33.4",
48
- "@constructive-io/graphql-env": "^3.34.4",
49
- "@constructive-io/graphql-types": "^3.33.4",
46
+ "@constructive-io/errors": "^0.22.0",
47
+ "@constructive-io/express-context": "^0.33.5",
48
+ "@constructive-io/graphql-env": "^3.34.5",
49
+ "@constructive-io/graphql-types": "^3.33.5",
50
50
  "@constructive-io/llm-env": "^0.15.0",
51
- "@constructive-io/query-builder": "^3.16.5",
51
+ "@constructive-io/query-builder": "^3.16.6",
52
52
  "@constructive-io/s3-utils": "^2.34.0",
53
53
  "@constructive-io/url-domains": "^2.31.0",
54
54
  "@graphile-contrib/pg-many-to-many": "2.0.0-rc.2",
55
- "@pgpmjs/env": "^2.46.1",
55
+ "@pgpmjs/env": "^2.46.2",
56
56
  "@pgpmjs/logger": "^2.26.0",
57
- "@pgpmjs/server-utils": "^3.29.4",
58
- "@pgpmjs/types": "^2.56.1",
57
+ "@pgpmjs/server-utils": "^3.29.5",
58
+ "@pgpmjs/types": "^2.56.2",
59
59
  "cors": "^2.8.6",
60
60
  "deepmerge": "^4.3.1",
61
61
  "express": "^5.2.1",
@@ -64,17 +64,17 @@
64
64
  "grafserv": "1.0.1",
65
65
  "graphile-build": "5.1.1",
66
66
  "graphile-build-pg": "5.1.3",
67
- "graphile-cache": "^4.14.4",
67
+ "graphile-cache": "^4.14.5",
68
68
  "graphile-config": "1.1.0",
69
- "graphile-function-bindings": "^1.17.5",
70
- "graphile-scoped-introspection": "^0.4.5",
71
- "graphile-settings": "^6.24.6",
69
+ "graphile-function-bindings": "^1.17.6",
70
+ "graphile-scoped-introspection": "^0.4.6",
71
+ "graphile-settings": "^6.24.7",
72
72
  "graphile-utils": "5.0.3",
73
73
  "graphql": "16.13.0",
74
74
  "graphql-upload": "^13.0.0",
75
75
  "lru-cache": "^11.2.7",
76
76
  "pg": "^8.21.0",
77
- "pg-cache": "^3.29.4",
77
+ "pg-cache": "^3.29.5",
78
78
  "pg-env": "^1.32.0",
79
79
  "pg-query-context": "^2.31.0",
80
80
  "pg-sql2": "5.0.1",
@@ -91,11 +91,11 @@
91
91
  "@types/request-ip": "^0.0.41",
92
92
  "@types/supertest": "^7.2.1",
93
93
  "cookie-parser": "^1.4.7",
94
- "graphile-test": "5.17.5",
94
+ "graphile-test": "5.17.6",
95
95
  "makage": "^0.8.0",
96
96
  "nodemon": "^3.1.14",
97
97
  "supertest": "^7.2.2",
98
98
  "ts-node": "^10.9.2"
99
99
  },
100
- "gitHead": "735479ba289c73a1cafb3a7a3e38dfd9c9a9dda7"
100
+ "gitHead": "31fb086361c3e2f3806d7945abe5074b3ce58f76"
101
101
  }