Skip to content

fix(formulus): load authored form schema version - #1045

Merged
najuna-brian merged 1 commit into
OpenDataEnsemble:devfrom
Grace256c:fix/909-form-schema-version
Nov 12, 2026
Merged

najuna-brian merged 1 commit into
OpenDataEnsemble:devfrom
Grace256c:fix/909-form-schema-version

Conversation

@Grace256c

@Grace256c Grace256c commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

What & Why

Formulus currently assigns every loaded form a hard-coded schemaVersion of "1.0", even when the form author has provided version metadata in schema.json.

This change resolves the authored form version from the root schema using the agreed precedence:

  1. non-empty string schemaVersion
  2. non-empty string version
  3. fallback to "1.0"

Blank, whitespace-only, missing, and non-string values fall through to the next valid option. The loaded schema itself is left unchanged.

After FormService loads the form, the resolved value is exposed as FormSpec.schemaVersion. Existing consumers such as FormCard continue to read that field through their current behavior, so no separate UI or WebView bridge change is required for #909.

This PR is intentionally limited to the FormService metadata-loading behavior covered by #909. Recording that version on newly created observations, along with persistence, Desktop, Formplayer alignment, and the related documentation correction, remains part of #950.

Type of Change

  • Bug fix
  • New feature / enhancement
  • Refactor / cleanup
  • Documentation
  • Chore / other

Component(s) Changed

  • formulus (React Native mobile app)
  • formulus-formplayer (form WebView UI)
  • synkronus (Go backend)
  • synkronus-cli (command-line client)
  • synkronus-portal (web admin UI)
  • desktop (Tauri app)
  • packages (tokens / components)
  • Documentation / DevOps / CI

Testing

  • Added/updated tests
  • Manually tested
  • Not applicable

Added table-driven coverage for:

  • valid root schemaVersion
  • valid legacy root version
  • schemaVersion precedence when both are present
  • schemas with no version metadata
  • blank and whitespace-only values
  • non-string schemaVersion and version values
  • fallback from invalid schemaVersion to valid version
  • fallback to "1.0" when neither candidate is valid
  • root-only metadata resolution
  • preservation of the loaded schema

Verification completed from formulus/:

  • pnpm run lint
  • pnpm run format
  • pnpm run format:check
  • pnpm run test --ci --watchAll=false
  • focused FormService.test.ts: 34/34 tests passed
  • full Formulus suite: 64 suites, 523 tests passed
  • git diff --check

Jest emits its existing force-exit warning for this test suite. The identical warning was reproduced on unchanged upstream/dev, confirming it is pre-existing and not introduced by this PR.

Checklist

  • Pre-flight checks for changed packages passed (lint / format / tests)
  • Breaking changes (if any) have migration steps
  • Related issue linked, e.g. Closes #123

Closes #909

@Grace256c

Copy link
Copy Markdown
Contributor Author

Hello @najuna-brian i have worked on this issue, could you please give review when you get a minute

@najuna-brian
najuna-brian self-requested a review November 12, 2026 07:15

@najuna-brian najuna-brian left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks Grace, looks good! The precedence matches what we agreed on #909, and the tests are solid. This is good to merge from my side. 🎉

@najuna-brian najuna-brian moved this from In progress to In review in ODE Community Board Nov 12, 2026
@najuna-brian
najuna-brian merged commit 6ecf0b2 into OpenDataEnsemble:dev Nov 12, 2026
13 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in ODE Community Board Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

fix(formulus): use form schema versions instead of calling every form v1.0

2 participants