Summary
The playground documentation lists appName as an implicit context field that the playground fills in for you. POST /api/admin/playground rejects a request without it with 400 BadDataError. The default exists only in the Admin UI, which injects appName: 'playground' before it posts; the API applies no default.
The sibling field in the same documented list, currentTime, is defaulted server-side, which is what makes this look like an oversight rather than a deliberate difference.
Tested on main at 3d91a51635859f13a5bc23547d323c19718629fb (unleash-server 8.1.0), OSS, stock config, Postgres 15, admin token.
What the docs say
https://docs.getunleash.io/concepts/playground, "Implicit context fields":
You can add any fields you want to the context used for the evaluation, and you can also leave out any fields you want. However, there are some fields that will be set for you if don't provide them:
appName: Unleash clients all require an appName to start up. If you do not provide an appName, the playground will assign a default value to this property instead.
currentTime: The currentTime property of the Unleash context gets auto-populated with the current time. You can override this manually by providing a value of your own.
Reproduction
Setup: one flag tcref-appname with a 100% flexibleRollout strategy, development enabled.
Control — with appName, the evaluation works:
POST /api/admin/playground
body: {"environment":"development","context":{"appName":"tcref","userId":"alice"}}
-> 200
{"input":{"environment":"development","context":{"appName":"tcref","userId":"alice"}},
"features":[{"isEnabled":true,"isEnabledInCurrentEnvironment":true, ... "name":"tcref-appname", ...}]}
The same request with appName left out:
POST /api/admin/playground
body: {"environment":"development","context":{"userId":"alice"}}
-> 400
{"id":"200cf8b4-59bb-45cc-bae7-1ebd869ff72b","name":"BadDataError",
"message":"Request validation failed: your request body or params contain invalid data. Refer to the `details` list for more information.",
"details":[{"path":"/body/context/appName","message":"The `/body/context/appName` property is required. It was not present on the data you sent."}]}
Where the difference comes from
-
src/lib/openapi/spec/sdk-context-schema.ts:7 — required: ['appName'], so the request never reaches the service.
-
frontend/src/component/playground/Playground/AdvancedPlayground.tsx:211-214 — the Admin UI supplies the default itself before posting:
const parsedContext = {
appName: 'playground',
...JSON.parse(context || '{}'),
};
-
currentTime, by contrast, is defaulted on the server: src/lib/features/playground/feature-evaluator/constraint.ts:119-121 falls back to new Date() when the context carries no currentTime.
So of the two fields documented as "set for you", one is handled by the server and one only by one particular client.
Either fix works
Default appName in the playground service (dropping it from sdkContextSchema's required, which would also let the Admin UI stop special-casing it), or amend the docs to say that the default is applied by the Admin UI and that the API requires appName. The first matches what the page currently promises.
Suggested labels: bug
Summary
The playground documentation lists
appNameas an implicit context field that the playground fills in for you.POST /api/admin/playgroundrejects a request without it with400 BadDataError. The default exists only in the Admin UI, which injectsappName: 'playground'before it posts; the API applies no default.The sibling field in the same documented list,
currentTime, is defaulted server-side, which is what makes this look like an oversight rather than a deliberate difference.Tested on
mainat3d91a51635859f13a5bc23547d323c19718629fb(unleash-server 8.1.0), OSS, stock config, Postgres 15, admin token.What the docs say
https://docs.getunleash.io/concepts/playground, "Implicit context fields":
Reproduction
Setup: one flag
tcref-appnamewith a 100%flexibleRolloutstrategy,developmentenabled.Control — with
appName, the evaluation works:The same request with
appNameleft out:Where the difference comes from
src/lib/openapi/spec/sdk-context-schema.ts:7—required: ['appName'], so the request never reaches the service.frontend/src/component/playground/Playground/AdvancedPlayground.tsx:211-214— the Admin UI supplies the default itself before posting:currentTime, by contrast, is defaulted on the server:src/lib/features/playground/feature-evaluator/constraint.ts:119-121falls back tonew Date()when the context carries nocurrentTime.So of the two fields documented as "set for you", one is handled by the server and one only by one particular client.
Either fix works
Default
appNamein the playground service (dropping it fromsdkContextSchema'srequired, which would also let the Admin UI stop special-casing it), or amend the docs to say that the default is applied by the Admin UI and that the API requiresappName. The first matches what the page currently promises.Suggested labels:
bug