Skip to content

Fix always-empty columns being dropped from variableMeasured#45

Merged
jodeleeuw merged 3 commits into
mainfrom
fix/always-empty-columns-variableMeasured
May 29, 2026
Merged

Fix always-empty columns being dropped from variableMeasured#45
jodeleeuw merged 3 commits into
mainfrom
fix/always-empty-columns-variableMeasured

Conversation

@htsukamoto5
Copy link
Copy Markdown
Contributor

Summary

  • Columns whose values are null, empty string, or the string "null" across every row in the dataset were silently omitted from variableMeasured, causing Psych-DS validation failures (the validator requires every CSV column header to have a corresponding entry)
  • Pre-register all column headers with a minimal stub (value: "unknown", description: "unknown") before the null-skip guard in generateObservation, so always-empty columns still appear in the output
  • When a real value is later encountered for a pre-registered column, generateMetadata upgrades value from "unknown" to the actual type, so columns with mixed empty/non-empty rows are unaffected

Test plan

  • Three new tests added to metadata-module.test.ts covering: all-empty cells, all-"null"-string values, and partially-empty columns (verifies type upgrades correctly from "unknown")
  • All 22 existing + new tests pass (npx jest in packages/metadata)
  • Manually validated against a real dataset with an always-empty eye_tracking_status column — entry appears in variableMeasured with "value": "unknown" and no levels/minValue/maxValue
  • Output passed the Psych-DS validator

🤖 Generated with Claude Code

htsukamoto5 and others added 2 commits May 29, 2026 10:42
Columns whose values are null/empty across the entire dataset were never
registered in variableMeasured, causing Psych-DS validation failures.

Pre-register every column header with value:"unknown" before the null-skip
guard so always-empty columns still appear in the output. When a real value
is later encountered, generateMetadata upgrades value:"unknown" to the
actual type.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Covers three cases: column with all empty cells, column with all "null"
string values, and column that is empty in some rows but has a real value
in others (verifies the type upgrades from "unknown" to the actual type).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 29, 2026

🦋 Changeset detected

Latest commit: e80e57c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@jspsych/metadata Patch
frontend Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Copy Markdown
Member

@jodeleeuw jodeleeuw left a comment

Choose a reason for hiding this comment

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

looks good to me!

@jodeleeuw
Copy link
Copy Markdown
Member

@htsukamoto5 the only thing missing is a changeset. This can be a patch bump.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jodeleeuw jodeleeuw merged commit 692ee1c into main May 29, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants