Resource change request fires even when no changes are made
Description
When a user visits the resource edit page and clicks save without making
any changes, the frontend still fires POST /api/resources/{id}/change_requests
with an empty payload:
{"change_request": {}}
Steps to Reproduce
- Navigate to any resource edit page e.g. /organizations/1077/edit
- Do not change any fields
- Click Save
- Open browser DevTools → Network tab
- Observe POST /api/resources/{id}/change_requests fires with body:
{"change_request": {}}
Root Cause
In app/pages/OrganizationEditPage.tsx, the save function compares each
resource field in state against the original API response to determine
if the resource was modified.
At line 1555, short_description is destructured from state:
const { short_description } = this.state;
At line 1572-1574, it is compared against the API response:
if (short_description !== resource.short_description) {
resourceChangeRequest.short_description = short_description;
resourceModified = true;
}
short_description has no input field on the edit page (line 860 declares
it as an optional state property but no onChange handler ever sets it),
so this.state.short_description is always undefined. However
resource.short_description returns a real string from the API for most
resources. This means:
undefined !== "some value from DB" → always true
→ resourceModified = true
→ request always fires
short_description itself never appears in the payload because
JSON.stringify silently drops undefined values, resulting in an empty
change_request object {}.
Expected Behaviour
POST /api/resources/{id}/change_requests should only fire when the user
has actually modified at least one resource field.
Actual Behaviour
The request fires on every save regardless of whether anything changed.
Impact
- Unnecessary API calls on every save
- Unnecessary change_requests rows inserted in the DB with no field_changes
- Noise in the change request audit trail
Suggested Fix
Either:
- Remove the short_description comparison from the save function since
there is no input field for it and it can never be changed via this page
- Or initialise this.state.short_description from the API response in
handleAPIGetResource so the comparison is meaningful
Resource change request fires even when no changes are made
Description
When a user visits the resource edit page and clicks save without making
any changes, the frontend still fires POST /api/resources/{id}/change_requests
with an empty payload:
{"change_request": {}}
Steps to Reproduce
{"change_request": {}}
Root Cause
In app/pages/OrganizationEditPage.tsx, the save function compares each
resource field in state against the original API response to determine
if the resource was modified.
At line 1555, short_description is destructured from state:
const { short_description } = this.state;
At line 1572-1574, it is compared against the API response:
if (short_description !== resource.short_description) {
resourceChangeRequest.short_description = short_description;
resourceModified = true;
}
short_description has no input field on the edit page (line 860 declares
it as an optional state property but no onChange handler ever sets it),
so this.state.short_description is always undefined. However
resource.short_description returns a real string from the API for most
resources. This means:
undefined !== "some value from DB" → always true
→ resourceModified = true
→ request always fires
short_description itself never appears in the payload because
JSON.stringify silently drops undefined values, resulting in an empty
change_request object {}.
Expected Behaviour
POST /api/resources/{id}/change_requests should only fire when the user
has actually modified at least one resource field.
Actual Behaviour
The request fires on every save regardless of whether anything changed.
Impact
Suggested Fix
Either:
there is no input field for it and it can never be changed via this page
handleAPIGetResource so the comparison is meaningful