From c2469ba5e9580ba6d14e95f60aedb1a572e6a634 Mon Sep 17 00:00:00 2001 From: paul Date: Wed, 23 Jul 2025 17:50:41 +0200 Subject: [PATCH] fix: Fix policy document format to send as object instead of double-stringified JSON MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Change generatePolicyFromTemplate to return object instead of string - Update CreatePolicyRequest interface to accept string | object for policy - Update CreatePolicyDialog to stringify policy object only when needed - Fix QuickStartWizard to send policy object directly to API This fixes the 'Proxy error' when creating policies as the backend was receiving double-stringified JSON which failed validation. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- frontend/src/components/Policies/CreatePolicyDialog.tsx | 4 ++-- frontend/src/services/policyService.ts | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/frontend/src/components/Policies/CreatePolicyDialog.tsx b/frontend/src/components/Policies/CreatePolicyDialog.tsx index bd7342b..5ecd042 100644 --- a/frontend/src/components/Policies/CreatePolicyDialog.tsx +++ b/frontend/src/components/Policies/CreatePolicyDialog.tsx @@ -74,7 +74,7 @@ const CreatePolicyDialog: React.FC = ({ const generatePreview = () => { if (bucketName && selectedTemplate) { const generatedPolicy = policyService.generatePolicyFromTemplate(selectedTemplate, bucketName); - setCustomPolicy(generatedPolicy); + setCustomPolicy(JSON.stringify(generatedPolicy, null, 2)); } }; @@ -111,7 +111,7 @@ const CreatePolicyDialog: React.FC = ({ setError('Bucket name is required'); return; } - policyToCreate = policyService.generatePolicyFromTemplate(selectedTemplate, bucketName); + policyToCreate = JSON.stringify(policyService.generatePolicyFromTemplate(selectedTemplate, bucketName), null, 2); } if (!validatePolicy()) { diff --git a/frontend/src/services/policyService.ts b/frontend/src/services/policyService.ts index f8a6783..d25a031 100644 --- a/frontend/src/services/policyService.ts +++ b/frontend/src/services/policyService.ts @@ -12,7 +12,7 @@ export interface Policy { export interface CreatePolicyRequest { name: string; - policy: string; + policy: string | object; } export interface AttachPolicyRequest { @@ -220,13 +220,12 @@ class PolicyService { } // Generate policy from template - generatePolicyFromTemplate(templateKey: string, bucketName: string): string { + generatePolicyFromTemplate(templateKey: string, bucketName: string): object { const template = policyTemplates[templateKey]; if (!template) { throw new Error('Invalid template'); } - const policy = template.generatePolicy(bucketName); - return JSON.stringify(policy, null, 2); + return template.generatePolicy(bucketName); } }