fix(AppResources): default SpAppResource.description to name on creation#7985
fix(AppResources): default SpAppResource.description to name on creation#7985foozleface wants to merge 2 commits into
Conversation
The frontend "New Resource" path constructed SpAppResource without a description, persisting NULL. Specify 6 hard-fails when opening labels backed by such rows. Mirror the backend report_runner behavior, which already defaults description to name. Refs ticket specify#824.
Iwantexpresso
left a comment
There was a problem hiding this comment.
-
npx jest --testPathPattern CreateAppResource— 4/4 pass (3 existing + 1 new) - Manually create a new App Resource via User Tools → App Resources → New Resource and confirm
spappresource.Descriptionis non-NULL in the DB - Open the new resource as a label/report in Specify 6 and confirm it no longer crashes
jest test results
Whenever the resource created the description field for the spappresource is currently staying as null. I have tried with creating 3 different app resources so far. I am a little unsure how request changes would whirl for this pr but I assume it wouldn't hurt just placing this in as one for now
The previous commit defaulted description in Create.tsx, but that resource is discarded: EditAppResource's onSaving returns false (per specify#1596) and navigates to the editor URL, where EditorWrapper builds a fresh skeleton from the URL params. That skeleton had no description, so spappresource.Description was still persisted as NULL — as observed in review testing. Move the default into the EditorWrapper skeleton (newAppResourceSkeleton) so the record that is actually saved carries description = name. Applies to both SpAppResource and SpViewSetObj, which both have the column. Refs ticket specify#824.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR refactors description-defaulting logic for app resources into two reusable helper functions: ChangesApp Resource Description Defaulting
🚥 Pre-merge checks | ✅ 5 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Good catch — description was indeed still NULL. Root cause: the resource built in Create.tsx is never the one that gets saved. 5cfaccc moves the default onto that skeleton ( |
Summary
The "New Resource" flow in
AppResources/Create.tsxconstructs anSpAppResourcewithout adescription, so the row is persisted withDescription = NULL. The backendreport_runnercreate path already defaultsdescription = name; this PR makes the frontend match.Specify 6 hard-fails when opening a label whose underlying
spappresource.Descriptionis NULL, so any site still running S6 alongside S7 hits this immediately. Reported as Specify support ticket #824 — Grant confirmed the analysis and asked for a PR.Changes
buildNewAppResource()helper inCreate.tsx; defaultsdescription: name.trim()exportsForTests(same pattern asgetUrlin this file)description === name.trim()Note for sites running both S6 and S7
If you already have rows with
Description IS NULL, S6 will still hard-fail on them after this PR is merged — this fix only prevents new NULL rows. A one-time backfill is safe and cheap (description is a simple text label, free-form):Test plan
npx jest --testPathPattern CreateAppResource— 4/4 pass (3 existing + 1 new)spappresource.Descriptionis non-NULL in the DBSummary by CodeRabbit
Bug Fixes
Tests