Skip to content

fix(AppResources): default SpAppResource.description to name on creation#7985

Open
foozleface wants to merge 1 commit intospecify:mainfrom
calacademy-research:cas/fix-spappresource-null-description
Open

fix(AppResources): default SpAppResource.description to name on creation#7985
foozleface wants to merge 1 commit intospecify:mainfrom
calacademy-research:cas/fix-spappresource-null-description

Conversation

@foozleface
Copy link
Copy Markdown
Collaborator

Summary

The "New Resource" flow in AppResources/Create.tsx constructs an SpAppResource without a description, so the row is persisted with Description = NULL. The backend report_runner create path already defaults description = name; this PR makes the frontend match.

Specify 6 hard-fails when opening a label whose underlying spappresource.Description is 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

  • Extract buildNewAppResource() helper in Create.tsx; defaults description: name.trim()
  • Export the helper via exportsForTests (same pattern as getUrl in this file)
  • Add a unit test asserting the new resource has 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):

-- Run once per Specify database; backfills any historic NULL descriptions
-- so Specify 6 stops crashing on labels created by Specify 7.
UPDATE spappresource SET Description = Name WHERE Description IS NULL;

Test plan

  • 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.Description is non-NULL in the DB
  • Open the new resource as a label/report in Specify 6 and confirm it no longer crashes

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.
Copy link
Copy Markdown
Contributor

@Iwantexpresso Iwantexpresso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 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.Description is 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

Image

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

@github-project-automation github-project-automation Bot moved this from 📋Back Log to Dev Attention Needed in General Tester Board Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Dev Attention Needed

Development

Successfully merging this pull request may close these issues.

2 participants