This is an automated email from the ASF dual-hosted git repository.
moonming pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-dashboard.git
The following commit(s) were added to refs/heads/master by this push:
new 453a0b564 fix(upstream): allow arbitrary key-value pairs in
discovery_args (#3377)
453a0b564 is described below
commit 453a0b5649ab7340c52588a16e38cbeb5e7f4a91
Author: SinhSinh An <[email protected]>
AuthorDate: Tue May 19 18:30:03 2026 -0500
fix(upstream): allow arbitrary key-value pairs in discovery_args (#3377)
* fix(upstream): allow arbitrary key-value pairs in discovery_args
The Zod schema for `discovery_args` used `z.object({})`, which strips
all unknown properties during parsing. This caused any user-entered
JSON for Discovery Args to be silently reduced to an empty object `{}`
before reaching the API.
Replace with `z.record(z.string(), z.unknown())` to preserve arbitrary
key-value pairs, consistent with how `Plugin` is typed in `plugins.ts`.
Fixes #3376
* test(upstream): add unit tests for discovery_args schema
Add Vitest unit tests verifying that the UpstreamDiscovery schema
correctly preserves arbitrary key-value pairs in discovery_args:
- Preserves flat key-value pairs (e.g., group_name, namespace_id)
- Preserves nested values (e.g., metadata objects)
- Accepts empty discovery_args
- Accepts missing (undefined) discovery_args
---
package.json | 1 +
pnpm-lock.yaml | 237 ++++++++++++++++++++++++++++++
src/types/schema/apisix/upstreams.test.ts | 80 ++++++++++
src/types/schema/apisix/upstreams.ts | 2 +-
4 files changed, 319 insertions(+), 1 deletion(-)
diff --git a/package.json b/package.json
index 00345cf88..985455397 100644
--- a/package.json
+++ b/package.json
@@ -90,6 +90,7 @@
"unplugin-info": "^1.2.2",
"vite": "^6.3.6",
"vite-tsconfig-paths": "^5.1.4",
+ "vitest": "^4.1.4",
"yaml": "^2.8.3"
},
"lint-staged": {
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 2243710dc..aec95b7ce 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -250,6 +250,9 @@ importers:
vite-tsconfig-paths:
specifier: ^5.1.4
version:
5.1.4([email protected])([email protected](@types/[email protected])([email protected])([email protected]([email protected]))([email protected])([email protected]))
+ vitest:
+ specifier: ^4.1.4
+ version:
4.1.4(@types/[email protected])([email protected](@types/[email protected])([email protected])([email protected]([email protected]))([email protected])([email protected]))
yaml:
specifier: ^2.8.3
version: 2.8.3
@@ -1305,6 +1308,9 @@ packages:
'@rtsao/[email protected]':
resolution: {integrity:
sha512-zt6OdqaDoOnJ1ZYsCYGt9YmWzDXl4vQdKTyJev62gFhRGKdx7mcT54V9KIjg+d2wi9EXsPvAPKe7i7WjfVWB8g==}
+ '@standard-schema/[email protected]':
+ resolution: {integrity:
sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==}
+
'@standard-schema/[email protected]':
resolution: {integrity:
sha512-e7Mew686owMaPJVNNLs55PUvgz371nKgwsc4vxE49zsODpJEnxgxRo2y/OKrqueavXgZNMDVj3DdHFlaSAeU8g==}
@@ -1553,6 +1559,12 @@ packages:
'@tybys/[email protected]':
resolution: {integrity:
sha512-9tTaPJLSiejZKx+Bmog4uSubteqTvFrVrURwkmHixBo0G4seD0zUxp98E1DzUBJxLQ3NPwXrGKDiVjwx/DpPsg==}
+ '@types/[email protected]':
+ resolution: {integrity:
sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==}
+
+ '@types/[email protected]':
+ resolution: {integrity:
sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==}
+
'@types/[email protected]':
resolution: {integrity:
sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==}
@@ -1756,6 +1768,35 @@ packages:
peerDependencies:
vite: ^4 || ^5 || ^6 || ^7
+ '@vitest/[email protected]':
+ resolution: {integrity:
sha512-iPBpra+VDuXmBFI3FMKHSFXp3Gx5HfmSCE8X67Dn+bwephCnQCaB7qWK2ldHa+8ncN8hJU8VTMcxjPpyMkUjww==}
+
+ '@vitest/[email protected]':
+ resolution: {integrity:
sha512-R9HTZBhW6yCSGbGQnDnH3QHfJxokKN4KB+Yvk9Q1le7eQNYwiCyKxmLmurSpFy6BzJanSLuEUDrD+j97Q+ZLPg==}
+ peerDependencies:
+ msw: ^2.4.9
+ vite: ^6.0.0 || ^7.0.0 || ^8.0.0
+ peerDependenciesMeta:
+ msw:
+ optional: true
+ vite:
+ optional: true
+
+ '@vitest/[email protected]':
+ resolution: {integrity:
sha512-ddmDHU0gjEUyEVLxtZa7xamrpIefdEETu3nZjWtHeZX4QxqJ7tRxSteHVXJOcr8jhiLoGAhkK4WJ3WqBpjx42A==}
+
+ '@vitest/[email protected]':
+ resolution: {integrity:
sha512-xTp7VZ5aXP5ZJrn15UtJUWlx6qXLnGtF6jNxHepdPHpMfz/aVPx+htHtgcAL2mDXJgKhpoo2e9/hVJsIeFbytQ==}
+
+ '@vitest/[email protected]':
+ resolution: {integrity:
sha512-MCjCFgaS8aZz+m5nTcEcgk/xhWv0rEH4Yl53PPlMXOZ1/Ka2VcZU6CJ+MgYCZbcJvzGhQRjVrGQNZqkGPttIKw==}
+
+ '@vitest/[email protected]':
+ resolution: {integrity:
sha512-XxNdAsKW7C+FLydqFJLb5KhJtl3PGCMmYwFRfhvIgxJvLSXhhVI1zM8f1qD3Zg7RCjTSzDVyct6sghs9UEgBEQ==}
+
+ '@vitest/[email protected]':
+ resolution: {integrity:
sha512-13QMT+eysM5uVGa1rG4kegGYNp6cnQcsTc67ELFbhNLQO+vgsygtYJx2khvdt4gVQqSSpC/KT5FZZxUpP3Oatw==}
+
'@xobotyi/[email protected]':
resolution: {integrity:
sha512-N8tkAACJx2ww8vFMneJmaAgmjAG1tnVBZJRLRcx061tmsLRZHSEZSLuGWnwPtunsSLvSqXQ2wfp7Mgqg1I+2dQ==}
@@ -1849,6 +1890,10 @@ packages:
resolution: {integrity:
sha512-uLvq6KJu04qoQM6gvBfKFjlh6Gl0vOKQuR5cJMDHQkmwfMOQeN3F3SHCv9SNYSL+CRoHvOGFfllDlVz03GQjvQ==}
engines: {node: '>=12.0.0'}
+ [email protected]:
+ resolution: {integrity:
sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==}
+ engines: {node: '>=12'}
+
[email protected]:
resolution: {integrity:
sha512-6t10qk83GOG8p0vKmaCr8eiilZwO171AvbROMtvvNiwrTly62t+7XkA8RdIIVbpMhCASAsxgAzdRSwh6nw/5Dg==}
engines: {node: '>=4'}
@@ -1934,6 +1979,10 @@ packages:
[email protected]:
resolution: {integrity:
sha512-tmN+fJxroPndC74efCdp12j+0rk0RHwV5Jwa1zWaFVyw2ZxAuPeG8ZgWC3Wz7uSjT3qMRQ5XHZ4COgQmsCMJAQ==}
+ [email protected]:
+ resolution: {integrity:
sha512-NUPRluOfOiTKBKvWPtSD4PhFvWCqOi0BGStNWs57X9js7XGTprSmFoz5F0tWhR4WPjNeR9jXqdC7/UpSJTnlRg==}
+ engines: {node: '>=18'}
+
[email protected]:
resolution: {integrity:
sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==}
engines: {node: '>=10'}
@@ -2151,6 +2200,9 @@ packages:
resolution: {integrity:
sha512-04cg8iJFDOxWcYlu0GFFWgs7vtaEPCmr5w1nrj9V3z3axu/48HCMwK6VMp45Zh3ZB+xLP1ifbJfrq86+1ypKKQ==}
engines: {node: '>= 0.4'}
+ [email protected]:
+ resolution: {integrity:
sha512-5POEcUuZybH7IdmGsD8wlf0AI55wMecM9rVBTI/qEAy2c1kTOm3DjFYjrBdI2K3BaJjJYfYFeRtM0t9ssnRuxw==}
+
[email protected]:
resolution: {integrity:
sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==}
engines: {node: '>= 0.4'}
@@ -2335,6 +2387,9 @@ packages:
resolution: {integrity:
sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==}
engines: {node: '>=4.0'}
+ [email protected]:
+ resolution: {integrity:
sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==}
+
[email protected]:
resolution: {integrity:
sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==}
engines: {node: '>=0.10.0'}
@@ -2346,6 +2401,10 @@ packages:
resolution: {integrity:
sha512-VyhnebXciFV2DESc+p6B+y0LjSm0krU4OgJN44qFAhBY0TJ+1V61tYD2+wHusZ6F9n5K+vl8k0sTy7PEfV4qpg==}
engines: {node: '>=16.17'}
+ [email protected]:
+ resolution: {integrity:
sha512-knvyeauYhqjOYvQ66MznSMs83wmHrCycNEN6Ao+2AeYEfxUIkuiVxdEa1qlGEPK+We3n0THiDciYSsCcgW/DoA==}
+ engines: {node: '>=12.0.0'}
+
[email protected]:
resolution: {integrity:
sha512-LmDxfWXwcTArk8fUEnOfSZpHOJ6zOMUJKOtFLFqJLoKJetuQG874Uc7/Kki7zFLzYybmZhp1M7+98pfMqeX8yA==}
@@ -2861,6 +2920,9 @@ packages:
[email protected]:
resolution: {integrity:
sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==}
+ [email protected]:
+ resolution: {integrity:
sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==}
+
[email protected]:
resolution: {integrity:
sha512-qXUm7e/YKFoqFPYPa3Ukg9xlI5cyAtGmyEIzMfW//m6kXwCy2Ps9DYf5ioijFKQ8qyuscrHoY04iJGctu2Kg0Q==}
engines: {node: '>= 18'}
@@ -3010,6 +3072,9 @@ packages:
resolution: {integrity:
sha512-gXah6aZrcUxjWg2zR2MwouP2eHlCBzdV4pygudehaKXSGW4v2AsRQUK+lwwXhii6KFZcunEnmSUoYp5CXibxtA==}
engines: {node: '>= 0.4'}
+ [email protected]:
+ resolution: {integrity:
sha512-uTqF9MuPraAQ+IsnPf366RG4cP9RtUi7MLO1N3KEc+wb0a6yKpeL0lmk2IB1jY5KHPAlTc6T/JRdC/YqxHNwkQ==}
+
[email protected]:
resolution: {integrity:
sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==}
engines: {node: '>=12'}
@@ -3690,6 +3755,9 @@ packages:
resolution: {integrity:
sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==}
engines: {node: '>= 0.4'}
+ [email protected]:
+ resolution: {integrity:
sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==}
+
[email protected]:
resolution: {integrity:
sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==}
engines: {node: '>=14'}
@@ -3735,6 +3803,9 @@ packages:
[email protected]:
resolution: {integrity:
sha512-mwnua/hkqM6pF4k8SnmZ2zfETsRUpWXREfA/goT8SLCV4iOFa4bzOX2nDipWAZFPTjLvQB82f5yaodMVhK0yJQ==}
+ [email protected]:
+ resolution: {integrity:
sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==}
+
[email protected]:
resolution: {integrity:
sha512-oeVtt7eWQS+Na6F//S4kJ2K2VbRlS9D43mAlMyVpVWovy9o+jfgH8O9agzANzaiLjclA0oYzUXEM4PurhSUChw==}
@@ -3747,6 +3818,9 @@ packages:
[email protected]:
resolution: {integrity:
sha512-HTEHMNieakEnoe33shBYcZ7NX83ACUjCu8c40iOGEZsngj9zRnkqS9j1pqQPXwobB0ZcVTk27REb7COQ0UR59w==}
+ [email protected]:
+ resolution: {integrity:
sha512-Rq7ybcX2RuC55r9oaPVEW7/xu3tj8u4GeBYHBWCychFtzMIr86A7e3PPEBPT37sHStKX3+TiX/Fr/ACmJLVlLQ==}
+
[email protected]:
resolution: {integrity:
sha512-eLoXW/DHyl62zxY4SCaIgnRhuMr6ri4juEYARS8E6sCEqzKpOiE521Ucofdx+KnDZl5xmvGYaaKCk5FEOxJCoQ==}
engines: {node: '>= 0.4'}
@@ -3842,6 +3916,9 @@ packages:
[email protected]:
resolution: {integrity:
sha512-+FbBPE1o9QAYvviau/qC5SE3caw21q3xkvWKBtja5vgqOWIHHJ3ioaq1VPfn/Szqctz2bU/oYeKd9/z5BL+PVg==}
+ [email protected]:
+ resolution: {integrity:
sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==}
+
[email protected]:
resolution: {integrity:
sha512-XPaBkWQJdsf3pLKJV9p4qN/S+fm2Oj8AIPo1BTUhg5oxkvm9+SVEGFdhyOz7tTdUTfvxMiAs4sp6/eZO2Ew+pw==}
@@ -3853,6 +3930,10 @@ packages:
resolution: {integrity:
sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==}
engines: {node: '>=12.0.0'}
+ [email protected]:
+ resolution: {integrity:
sha512-Bf+ILmBgretUrdJxzXM0SgXLZ3XfiaUuOj/IKQHuTXip+05Xn+uyEYdVg0kYDipTBcLrCVyUzAPz7QmArb0mmw==}
+ engines: {node: '>=14.0.0'}
+
[email protected]:
resolution: {integrity:
sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==}
engines: {node: '>=8.0'}
@@ -4126,6 +4207,47 @@ packages:
yaml:
optional: true
+ [email protected]:
+ resolution: {integrity:
sha512-tFuJqTxKb8AvfyqMfnavXdzfy3h3sWZRWwfluGbkeR7n0HUev+FmNgZ8SDrRBTVrVCjgH5cA21qGbCffMNtWvg==}
+ engines: {node: ^20.0.0 || ^22.0.0 || >=24.0.0}
+ hasBin: true
+ peerDependencies:
+ '@edge-runtime/vm': '*'
+ '@opentelemetry/api': ^1.9.0
+ '@types/node': ^20.0.0 || ^22.0.0 || >=24.0.0
+ '@vitest/browser-playwright': 4.1.4
+ '@vitest/browser-preview': 4.1.4
+ '@vitest/browser-webdriverio': 4.1.4
+ '@vitest/coverage-istanbul': 4.1.4
+ '@vitest/coverage-v8': 4.1.4
+ '@vitest/ui': 4.1.4
+ happy-dom: '*'
+ jsdom: '*'
+ vite: ^6.0.0 || ^7.0.0 || ^8.0.0
+ peerDependenciesMeta:
+ '@edge-runtime/vm':
+ optional: true
+ '@opentelemetry/api':
+ optional: true
+ '@types/node':
+ optional: true
+ '@vitest/browser-playwright':
+ optional: true
+ '@vitest/browser-preview':
+ optional: true
+ '@vitest/browser-webdriverio':
+ optional: true
+ '@vitest/coverage-istanbul':
+ optional: true
+ '@vitest/coverage-v8':
+ optional: true
+ '@vitest/ui':
+ optional: true
+ happy-dom:
+ optional: true
+ jsdom:
+ optional: true
+
[email protected]:
resolution: {integrity:
sha512-Dhxzh5HZuiHQhbvTW9AMetFfBHDMYpo23Uo9btPXgdYP+3T5S+p+jgNy7spra+veYhBP2dCSgxR/i2Y02h5/6w==}
engines: {node: '>=0.10.0'}
@@ -4157,6 +4279,11 @@ packages:
engines: {node: '>= 8'}
hasBin: true
+ [email protected]:
+ resolution: {integrity:
sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==}
+ engines: {node: '>=8'}
+ hasBin: true
+
[email protected]:
resolution: {integrity:
sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==}
engines: {node: '>=0.10.0'}
@@ -5334,6 +5461,8 @@ snapshots:
'@rtsao/[email protected]': {}
+ '@standard-schema/[email protected]': {}
+
'@standard-schema/[email protected]': {}
'@svgr/[email protected](@babel/[email protected])':
@@ -5574,6 +5703,13 @@ snapshots:
tslib: 2.8.1
optional: true
+ '@types/[email protected]':
+ dependencies:
+ '@types/deep-eql': 4.0.2
+ assertion-error: 2.0.1
+
+ '@types/[email protected]': {}
+
'@types/[email protected]': {}
'@types/[email protected]': {}
@@ -5768,6 +5904,47 @@ snapshots:
transitivePeerDependencies:
- '@swc/helpers'
+ '@vitest/[email protected]':
+ dependencies:
+ '@standard-schema/spec': 1.1.0
+ '@types/chai': 5.2.3
+ '@vitest/spy': 4.1.4
+ '@vitest/utils': 4.1.4
+ chai: 6.2.2
+ tinyrainbow: 3.1.0
+
+
'@vitest/[email protected]([email protected](@types/[email protected])([email protected])([email protected]([email protected]))([email protected])([email protected]))':
+ dependencies:
+ '@vitest/spy': 4.1.4
+ estree-walker: 3.0.3
+ magic-string: 0.30.21
+ optionalDependencies:
+ vite:
6.4.1(@types/[email protected])([email protected])([email protected]([email protected]))([email protected])([email protected])
+
+ '@vitest/[email protected]':
+ dependencies:
+ tinyrainbow: 3.1.0
+
+ '@vitest/[email protected]':
+ dependencies:
+ '@vitest/utils': 4.1.4
+ pathe: 2.0.3
+
+ '@vitest/[email protected]':
+ dependencies:
+ '@vitest/pretty-format': 4.1.4
+ '@vitest/utils': 4.1.4
+ magic-string: 0.30.21
+ pathe: 2.0.3
+
+ '@vitest/[email protected]': {}
+
+ '@vitest/[email protected]':
+ dependencies:
+ '@vitest/pretty-format': 4.1.4
+ convert-source-map: 2.0.0
+ tinyrainbow: 3.1.0
+
'@xobotyi/[email protected]': {}
[email protected]([email protected]):
@@ -5943,6 +6120,8 @@ snapshots:
pvutils: 1.1.5
tslib: 2.8.1
+ [email protected]: {}
+
[email protected]:
dependencies:
tslib: 2.8.1
@@ -6035,6 +6214,8 @@ snapshots:
[email protected]: {}
+ [email protected]: {}
+
[email protected]:
dependencies:
ansi-styles: 4.3.0
@@ -6306,6 +6487,8 @@ snapshots:
math-intrinsics: 1.1.0
safe-array-concat: 1.1.3
+ [email protected]: {}
+
[email protected]:
dependencies:
es-errors: 1.3.0
@@ -6583,6 +6766,10 @@ snapshots:
[email protected]: {}
+ [email protected]:
+ dependencies:
+ '@types/estree': 1.0.8
+
[email protected]: {}
[email protected]: {}
@@ -6599,6 +6786,8 @@ snapshots:
signal-exit: 4.1.0
strip-final-newline: 3.0.0
+ [email protected]: {}
+
[email protected]: {}
[email protected]: {}
@@ -7083,6 +7272,10 @@ snapshots:
dependencies:
yallist: 3.1.1
+ [email protected]:
+ dependencies:
+ '@jridgewell/sourcemap-codec': 1.5.5
+
[email protected]: {}
[email protected]: {}
@@ -7232,6 +7425,8 @@ snapshots:
define-properties: 1.2.1
es-object-atoms: 1.1.1
+ [email protected]: {}
+
[email protected]:
dependencies:
mimic-fn: 4.0.0
@@ -8056,6 +8251,8 @@ snapshots:
side-channel-map: 1.0.1
side-channel-weakmap: 1.0.2
+ [email protected]: {}
+
[email protected]: {}
[email protected]:
@@ -8097,6 +8294,8 @@ snapshots:
dependencies:
stackframe: 1.3.4
+ [email protected]: {}
+
[email protected]: {}
[email protected]:
@@ -8112,6 +8311,8 @@ snapshots:
[email protected]: {}
+ [email protected]: {}
+
[email protected]:
dependencies:
es-errors: 1.3.0
@@ -8213,6 +8414,8 @@ snapshots:
[email protected]: {}
+ [email protected]: {}
+
[email protected]: {}
[email protected]: {}
@@ -8222,6 +8425,8 @@ snapshots:
fdir: 6.5.0([email protected])
picomatch: 4.0.4
+ [email protected]: {}
+
[email protected]:
dependencies:
is-number: 7.0.0
@@ -8468,6 +8673,33 @@ snapshots:
tsx: 4.21.0
yaml: 2.8.3
+
[email protected](@types/[email protected])([email protected](@types/[email protected])([email protected])([email protected]([email protected]))([email protected])([email protected])):
+ dependencies:
+ '@vitest/expect': 4.1.4
+ '@vitest/mocker':
4.1.4([email protected](@types/[email protected])([email protected])([email protected]([email protected]))([email protected])([email protected]))
+ '@vitest/pretty-format': 4.1.4
+ '@vitest/runner': 4.1.4
+ '@vitest/snapshot': 4.1.4
+ '@vitest/spy': 4.1.4
+ '@vitest/utils': 4.1.4
+ es-module-lexer: 2.0.0
+ expect-type: 1.3.0
+ magic-string: 0.30.21
+ obug: 2.1.1
+ pathe: 2.0.3
+ picomatch: 4.0.4
+ std-env: 4.1.0
+ tinybench: 2.9.0
+ tinyexec: 1.0.2
+ tinyglobby: 0.2.15
+ tinyrainbow: 3.1.0
+ vite:
6.4.1(@types/[email protected])([email protected])([email protected]([email protected]))([email protected])([email protected])
+ why-is-node-running: 2.3.0
+ optionalDependencies:
+ '@types/node': 22.19.15
+ transitivePeerDependencies:
+ - msw
+
[email protected]: {}
[email protected]:
@@ -8521,6 +8753,11 @@ snapshots:
dependencies:
isexe: 2.0.0
+ [email protected]:
+ dependencies:
+ siginfo: 2.0.0
+ stackback: 0.0.2
+
[email protected]: {}
[email protected]:
diff --git a/src/types/schema/apisix/upstreams.test.ts
b/src/types/schema/apisix/upstreams.test.ts
new file mode 100644
index 000000000..e531d8fcd
--- /dev/null
+++ b/src/types/schema/apisix/upstreams.test.ts
@@ -0,0 +1,80 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import { describe, expect, it } from 'vitest';
+
+import { APISIXUpstreams } from './upstreams';
+
+describe('UpstreamDiscovery schema', () => {
+ it('should preserve arbitrary key-value pairs in discovery_args', () => {
+ const input = {
+ discovery_type: 'dns',
+ service_name: 'my-service',
+ discovery_args: {
+ group_name: 'my-group',
+ namespace_id: 'public',
+ },
+ };
+
+ const result = APISIXUpstreams.UpstreamDiscovery.parse(input);
+
+ expect(result.discovery_args).toEqual({
+ group_name: 'my-group',
+ namespace_id: 'public',
+ });
+ });
+
+ it('should accept discovery_args with nested values', () => {
+ const input = {
+ discovery_type: 'nacos',
+ service_name: 'my-service',
+ discovery_args: {
+ group_name: 'DEFAULT_GROUP',
+ metadata: { version: 'v1', env: 'prod' },
+ },
+ };
+
+ const result = APISIXUpstreams.UpstreamDiscovery.parse(input);
+
+ expect(result.discovery_args).toEqual({
+ group_name: 'DEFAULT_GROUP',
+ metadata: { version: 'v1', env: 'prod' },
+ });
+ });
+
+ it('should accept empty discovery_args', () => {
+ const input = {
+ discovery_type: 'dns',
+ service_name: 'my-service',
+ discovery_args: {},
+ };
+
+ const result = APISIXUpstreams.UpstreamDiscovery.parse(input);
+
+ expect(result.discovery_args).toEqual({});
+ });
+
+ it('should accept missing discovery_args', () => {
+ const input = {
+ discovery_type: 'dns',
+ service_name: 'my-service',
+ };
+
+ const result = APISIXUpstreams.UpstreamDiscovery.parse(input);
+
+ expect(result.discovery_args).toBeUndefined();
+ });
+});
diff --git a/src/types/schema/apisix/upstreams.ts
b/src/types/schema/apisix/upstreams.ts
index 2a582a9ac..ed347d3f6 100644
--- a/src/types/schema/apisix/upstreams.ts
+++ b/src/types/schema/apisix/upstreams.ts
@@ -72,7 +72,7 @@ const UpstreamNodeListOrObj = z.union([UpstreamNodes,
UpstreamNodeObj]);
const UpstreamDiscovery = z.object({
discovery_type: z.string().optional(),
service_name: z.string().optional(),
- discovery_args: z.object({}).optional(),
+ discovery_args: z.record(z.string(), z.unknown()).optional(),
});
const UpstreamTimeout = z.object({