Skip to content

Handle empty data in system info during setup - #8415

Open
CarolineDenis wants to merge 13 commits into
mainfrom
issue-8387
Open

Handle empty data in system info during setup #8415
CarolineDenis wants to merge 13 commits into
mainfrom
issue-8387

Conversation

@CarolineDenis

@CarolineDenis CarolineDenis commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Fixes #8387

Checklist

  • Self-review the PR after opening it to make sure the changes look good and
    self-explanatory (or properly documented)
  • Add relevant issue to release milestone
  • Add pr to documentation list
  • Add automated tests
  • Add a reverse migration if a migration is present in the PR
  • Add migration function to
    def fix_schema_config(stdout: WriteToStdOut | None = None):

Testing instructions

  • Open Specify with an empty DB
  • Verify you land on the guided setup
  • When confirming open a second tab with {your_base_url}/context/system_info.json
  • Verify it loads with null values for missing data
  • Complete de setup
  • When you are on the Specify splash screen, reload your second tab with cache disabled
  • Verify it loads with the correct data

Summary by CodeRabbit

  • New Features

    • Added setup completion status to system information.
    • Added discipline type, global geography status, and secondary statistics details.
  • Bug Fixes

    • Improved behavior when system information is incomplete during guided setup.
    • Prevented missing metadata from causing errors in statistics, tree creation, configuration, and navigation.
    • Improved handling of version information when database details are unavailable.
  • Tests

    • Added coverage for system information before and after guided setup completion.

@CarolineDenis CarolineDenis added this to the 7.12.2 milestone Aug 12, 2026
@github-actions

Copy link
Copy Markdown

Warning

One or more dependencies are approaching or past End-of-Life.
Please plan upgrades accordingly.

STATUS=WARNING
NODE_VERSION=20
NODE_CYCLE=20
EOL_DATE=2026-04-30
DAYS_REMAINING=-104

--- Node.js ---
Version: 20
EOL: 2026-04-30
Status: WARNING

STATUS=OK
PYTHON_VERSION=3.12
PYTHON_CYCLE=3.12
EOL_DATE=2028-10-31
DAYS_REMAINING=811

--- Python ---
Version: 3.12
EOL: 2028-10-31
Status: OK

STATUS=WARNING
DJANGO_VERSION=4.2
DJANGO_CYCLE=4.2
EOL_DATE=2026-04-07
DAYS_REMAINING=-127

--- Django ---
Version: 4.2
EOL: 2026-04-07
Status: WARNING


@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d313c963-9c9c-4441-88bf-27b6efbbc9da

📥 Commits

Reviewing files that changed from the base of the PR and between 0decb0a and 32f658b.

📒 Files selected for processing (1)
  • specifyweb/frontend/js_src/lib/components/WbPlanView/navigator.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • specifyweb/frontend/js_src/lib/components/WbPlanView/navigator.ts

📝 Walkthrough

Walkthrough

The system information endpoint now works before guided setup completes. It reports setup status and nullable metadata. Frontend types, statistics requests, tree creation, hierarchy configuration, navigation, fixtures, and tests handle incomplete setup safely.

Changes

Guided setup system information

Layer / File(s) Summary
Setup status and safe endpoint payload
specifyweb/backend/setup_tool/api.py, specifyweb/backend/context/views.py, specifyweb/backend/context/tests/test_system_info.py
The endpoint reports guided-setup completion, tolerates missing setup records, suppresses database and institution metadata before completion, and returns complete metadata after completion. Backend tests cover both states.
Nullable system information contract
specifyweb/frontend/js_src/lib/components/InitialContext/systemInfo.ts, specifyweb/frontend/js_src/lib/components/InitialContext/__tests__/systemInfo.test.ts, specifyweb/frontend/js_src/lib/tests/ajax/static/context/system_info.json, specifyweb/frontend/js_src/lib/components/Core/VersionMismatch.tsx
The frontend contract adds setup_complete and nullable metadata fields. Fixtures and expectations include the new fields. Version mismatch handling uses an empty database version when the value is nullish.
Frontend handling of incomplete setup
specifyweb/frontend/js_src/lib/components/InitialContext/stats.ts, specifyweb/frontend/js_src/lib/components/SystemConfigurationTool/Hierarchy.tsx, specifyweb/frontend/js_src/lib/components/TreeView/CreateTree.tsx, specifyweb/frontend/js_src/lib/components/WbPlanView/navigator.ts
Frontend consumers use empty-string fallbacks, require a collection GUID for Lambda statistics, default geography to false, and guard discipline-dependent navigation logic.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant system_info
  participant GuidedSetup
  participant InitialContext
  participant Statistics

  Client->>system_info: Request system_info.json
  system_info->>GuidedSetup: Check setup completion
  GuidedSetup-->>system_info: Return setup status
  system_info-->>InitialContext: Return nullable or complete metadata
  InitialContext->>Statistics: Send normalized request parameters
  Statistics-->>InitialContext: Return statistics response
Loading
🚥 Pre-merge checks | ✅ 5 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Testing Instructions ⚠️ Warning The PR's Testing instructions section contains only template comments, although the diff changes the system-info backend endpoint, setup detection, and multiple frontend consumers. Add executable backend and frontend test commands, plus endpoint checks for incomplete and complete Guided Setup. State expected nullable metadata, setup_complete, and frontend behavior.
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes prevent system_info.json errors before Guided Setup completes and add coverage for incomplete setup states [#8387].
Out of Scope Changes check ✅ Passed The backend, frontend, fixture, and test changes directly support nullable system information during incomplete Guided Setup.
Automatic Tests ✅ Passed The PR adds test_system_info.py with two discoverable endpoint tests covering incomplete and complete Guided Setup payloads, including HTTP 200 and key metadata assertions.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: preventing empty system information data from causing errors during Guided Setup.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-8387

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@specifyweb/backend/context/views.py`:
- Around line 726-728: In the exception handler surrounding collection lookup,
replace the broad Exception catch with Collection.DoesNotExist so only stale
collection cookies reset collection and discipline to None. Allow database
failures, empty-table IndexError, and other programming errors to propagate
normally.

In `@specifyweb/frontend/js_src/lib/components/Core/VersionMismatch.tsx`:
- Line 33: Update the version-mismatch enablement condition in VersionMismatch
so the dialog is shown only after setup is complete and
getSystemInfo().database_version is non-null; do not rely on the databaseVersion
fallback at the displayed description. Preserve the existing mismatch behavior
once both prerequisites are satisfied.

In `@specifyweb/frontend/js_src/lib/components/TreeView/CreateTree.tsx`:
- Around line 100-101: In CreateTree, use the discipline value from
getSystemInfo to block tree creation when it is empty, before setting
isTreeCreationStarted or invoking startTreeCreation; apply the same guard in the
ImportTree flow. When targeting connectedCollection, pass it through the
request’s collectionName field rather than collection so the backend uses the
intended specify_collection.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4367a886-809e-453b-a157-6bd5314abe17

📥 Commits

Reviewing files that changed from the base of the PR and between fb1c6d6 and 0decb0a.

📒 Files selected for processing (11)
  • specifyweb/backend/context/tests/test_system_info.py
  • specifyweb/backend/context/views.py
  • specifyweb/backend/setup_tool/api.py
  • specifyweb/frontend/js_src/lib/components/Core/VersionMismatch.tsx
  • specifyweb/frontend/js_src/lib/components/InitialContext/__tests__/systemInfo.test.ts
  • specifyweb/frontend/js_src/lib/components/InitialContext/stats.ts
  • specifyweb/frontend/js_src/lib/components/InitialContext/systemInfo.ts
  • specifyweb/frontend/js_src/lib/components/SystemConfigurationTool/Hierarchy.tsx
  • specifyweb/frontend/js_src/lib/components/TreeView/CreateTree.tsx
  • specifyweb/frontend/js_src/lib/components/WbPlanView/navigator.ts
  • specifyweb/frontend/js_src/lib/tests/ajax/static/context/system_info.json

Comment thread specifyweb/backend/context/views.py Outdated
Comment thread specifyweb/frontend/js_src/lib/components/Core/VersionMismatch.tsx Outdated
Comment thread specifyweb/frontend/js_src/lib/components/TreeView/CreateTree.tsx
@github-project-automation github-project-automation Bot moved this from 📋Back Log to Dev Attention Needed in General Tester Board Aug 12, 2026
Triggered by b6c9475 on branch refs/heads/issue-8387
@CarolineDenis
CarolineDenis requested a review from a team August 12, 2026 12:16
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.

Prevent /context/system_info.json from erroring before guided setup is complete

1 participant