fix: allow all environment variable fields in API endpoints
Fixes #6847 The API endpoints for environment variables were rejecting valid fields like is_buildtime, is_runtime, is_multiline, and is_shown_once with 422 errors, even though the code was using these fields internally. Changes: - Added missing fields to $allowedFields in create_env() - Added missing fields to $allowedFields in update_env_by_uuid() - Updated allowed fields in create_bulk_envs() - Added validation rules for is_runtime and is_buildtime 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
3dfef0b53a
commit
78031b991a
1 changed files with 9 additions and 3 deletions
|
|
@ -2492,7 +2492,7 @@ public function envs(Request $request)
|
||||||
)]
|
)]
|
||||||
public function update_env_by_uuid(Request $request)
|
public function update_env_by_uuid(Request $request)
|
||||||
{
|
{
|
||||||
$allowedFields = ['key', 'value', 'is_preview', 'is_literal'];
|
$allowedFields = ['key', 'value', 'is_preview', 'is_literal', 'is_multiline', 'is_shown_once', 'is_runtime', 'is_buildtime'];
|
||||||
$teamId = getTeamIdFromToken();
|
$teamId = getTeamIdFromToken();
|
||||||
|
|
||||||
if (is_null($teamId)) {
|
if (is_null($teamId)) {
|
||||||
|
|
@ -2520,6 +2520,8 @@ public function update_env_by_uuid(Request $request)
|
||||||
'is_literal' => 'boolean',
|
'is_literal' => 'boolean',
|
||||||
'is_multiline' => 'boolean',
|
'is_multiline' => 'boolean',
|
||||||
'is_shown_once' => 'boolean',
|
'is_shown_once' => 'boolean',
|
||||||
|
'is_runtime' => 'boolean',
|
||||||
|
'is_buildtime' => 'boolean',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$extraFields = array_diff(array_keys($request->all()), $allowedFields);
|
$extraFields = array_diff(array_keys($request->all()), $allowedFields);
|
||||||
|
|
@ -2715,7 +2717,7 @@ public function create_bulk_envs(Request $request)
|
||||||
], 400);
|
], 400);
|
||||||
}
|
}
|
||||||
$bulk_data = collect($bulk_data)->map(function ($item) {
|
$bulk_data = collect($bulk_data)->map(function ($item) {
|
||||||
return collect($item)->only(['key', 'value', 'is_preview', 'is_literal']);
|
return collect($item)->only(['key', 'value', 'is_preview', 'is_literal', 'is_multiline', 'is_shown_once', 'is_runtime', 'is_buildtime']);
|
||||||
});
|
});
|
||||||
$returnedEnvs = collect();
|
$returnedEnvs = collect();
|
||||||
foreach ($bulk_data as $item) {
|
foreach ($bulk_data as $item) {
|
||||||
|
|
@ -2726,6 +2728,8 @@ public function create_bulk_envs(Request $request)
|
||||||
'is_literal' => 'boolean',
|
'is_literal' => 'boolean',
|
||||||
'is_multiline' => 'boolean',
|
'is_multiline' => 'boolean',
|
||||||
'is_shown_once' => 'boolean',
|
'is_shown_once' => 'boolean',
|
||||||
|
'is_runtime' => 'boolean',
|
||||||
|
'is_buildtime' => 'boolean',
|
||||||
]);
|
]);
|
||||||
if ($validator->fails()) {
|
if ($validator->fails()) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
|
|
@ -2885,7 +2889,7 @@ public function create_bulk_envs(Request $request)
|
||||||
)]
|
)]
|
||||||
public function create_env(Request $request)
|
public function create_env(Request $request)
|
||||||
{
|
{
|
||||||
$allowedFields = ['key', 'value', 'is_preview', 'is_literal'];
|
$allowedFields = ['key', 'value', 'is_preview', 'is_literal', 'is_multiline', 'is_shown_once', 'is_runtime', 'is_buildtime'];
|
||||||
$teamId = getTeamIdFromToken();
|
$teamId = getTeamIdFromToken();
|
||||||
|
|
||||||
if (is_null($teamId)) {
|
if (is_null($teamId)) {
|
||||||
|
|
@ -2908,6 +2912,8 @@ public function create_env(Request $request)
|
||||||
'is_literal' => 'boolean',
|
'is_literal' => 'boolean',
|
||||||
'is_multiline' => 'boolean',
|
'is_multiline' => 'boolean',
|
||||||
'is_shown_once' => 'boolean',
|
'is_shown_once' => 'boolean',
|
||||||
|
'is_runtime' => 'boolean',
|
||||||
|
'is_buildtime' => 'boolean',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$extraFields = array_diff(array_keys($request->all()), $allowedFields);
|
$extraFields = array_diff(array_keys($request->all()), $allowedFields);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue