This commit is contained in:
Matt 2025-06-10 00:15:36 +02:00
parent b391db0253
commit 76d04a1e2a
2 changed files with 33 additions and 13 deletions

View File

@ -83,20 +83,35 @@
### 11. 404 Errors for Existing Records During Updates - FIXED ### 11. 404 Errors for Existing Records During Updates - FIXED
- **Problem**: Records that exist in the database return 404 when trying to update them - **Problem**: Records that exist in the database return 404 when trying to update them
- **Root Cause**: The update request was including webhook objects in the body that shouldn't be sent - **Root Cause**: Webhook objects were being sent in the request body
- **Solution**: - **Solution**: Now filtering out all object fields, only sending primitives
**What we've fixed:**
- Now skipping all object fields (including webhook fields) during updates - Now skipping all object fields (including webhook fields) during updates
- Only sending primitive values (strings, numbers, nulls) to the API - Only sending primitive values (strings, numbers, nulls) to the API
- Removed webhook fields from the allowed fields list - Removed webhook fields from the allowed fields list
- Added retry mechanism with exponential backoff (3 retries with 1s, 2s, 3s delays) - Added retry mechanism with exponential backoff
- Enhanced logging to show exact URLs, headers, and request bodies - Including `Id` field in request body to identify the record
**Fixed webhook fields that were causing the issue:** **Confirmed Working Format:**
- "Request More Information" (webhook object) ```javascript
- "Request More Info - To Sales" (webhook object) // URL: /api/v2/tables/mbs9hjauug4eseo/records (no ID in URL)
- "EOI Send to Sales" (webhook object) // Body: { Id: 459, "Full Name": "...", "Extra Comments": "..." }
```
These fields are now automatically filtered out during updates, preventing the 404 errors. **Test Results:**
- ✅ PATCH with single object: `{ Id: 459, ... }` - **WORKS**
- ✅ PATCH with array: `[{ Id: 459, ... }]` - **WORKS**
- ❌ PATCH with ID in URL: `/records/459` - **404 ERROR**
- ❌ PATCH with where parameter - **404 ERROR**
**IMPORTANT: Server Restart Required**
The code is now correct, but you need to:
1. **Restart your Docker container or development server**
2. **Verify the API token in your .env file matches the working one**
3. **Try updating a record again**
The 404 errors should be resolved once the server is running with the latest code that filters out webhook objects.
## Required Environment Variables ## Required Environment Variables

View File

@ -120,7 +120,11 @@ export const updateInterest = async (id: string, data: Partial<Interest>, retryC
console.log('[nocodb.updateInterest] Clean data fields:', Object.keys(cleanData)); console.log('[nocodb.updateInterest] Clean data fields:', Object.keys(cleanData));
const url = `${createTableUrl(Table.Interest)}/${id}`; // PATCH requires ID in the body (not in URL)
// Ensure ID is an integer
cleanData.Id = parseInt(id);
const url = createTableUrl(Table.Interest);
console.log('[nocodb.updateInterest] URL:', url); console.log('[nocodb.updateInterest] URL:', url);
try { try {
@ -129,6 +133,7 @@ export const updateInterest = async (id: string, data: Partial<Interest>, retryC
}); });
console.log('[nocodb.updateInterest] Request body:', JSON.stringify(cleanData, null, 2)); console.log('[nocodb.updateInterest] Request body:', JSON.stringify(cleanData, null, 2));
// Try sending as a single object first (as shown in the API docs)
const result = await $fetch<Interest>(url, { const result = await $fetch<Interest>(url, {
method: "PATCH", method: "PATCH",
headers: { headers: {