Skip to content

Conversation

@tchoumi313
Copy link
Contributor

@tchoumi313 tchoumi313 commented Dec 29, 2025

Personal data form was having an ID field but the model lacks a matching ref_id field

Summary by CodeRabbit

  • Bug Fixes
    • Fixed form field visibility: Reference ID field now correctly hides when no data is present.
    • Updated validation behavior for reference ID field handling in forms.

✏️ Tip: You can customize this high-level summary in your review settings.

@tchoumi313 tchoumi313 self-assigned this Dec 29, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 29, 2025

📝 Walkthrough

Walkthrough

The changes modify the ref_id field behavior across form and schema layers. A conditional hidden attribute hides the ref_id TextField when undefined, and the schema removes the default empty string value, making the field return undefined instead of an empty string when omitted.

Changes

Cohort / File(s) Summary
Form UI Display
frontend/src/lib/components/Forms/ModelForm/PersonalDataForm.svelte
Added conditional hidden attribute to ref_id TextField to hide field when initialData.ref_id is falsy
Schema Validation
frontend/src/lib/utils/schemas.ts
Removed default empty string ('') from ref_id field declaration; field now resolves to undefined instead of '' when omitted

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

A rabbit hides what shouldn't show,
When fields are none, they fade just so—
No default strings to fill the void,
Just undefined, and neatly void! 🐰✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: removing the ref_id field from the Personal Data form, which is the primary objective of this pull request.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 503c07e and df44d3f.

📒 Files selected for processing (2)
  • frontend/src/lib/components/Forms/ModelForm/PersonalDataForm.svelte
  • frontend/src/lib/utils/schemas.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: enterprise-startup-functional-test (3.12)
  • GitHub Check: startup-functional-test (3.12)
  • GitHub Check: build_enterprise_frontend
  • GitHub Check: enterprise-startup-docker-compose-test
  • GitHub Check: startup-docker-compose-test
  • GitHub Check: build_community_frontend
  • GitHub Check: Analyze (python)

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 and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
frontend/src/lib/utils/schemas.ts (1)

867-876: Critical: Commented-out field causes schema-form mismatch.

Commenting out ref_id removes it from the schema entirely, but PersonalDataForm.svelte still references field="ref_id". This mismatch will cause form validation and submission to fail or ignore the field since it's not defined in the schema.

If the goal is to remove ref_id because the backend model doesn't support it, remove the corresponding TextField from PersonalDataForm.svelte (lines 28-35) entirely instead of just hiding it. Alternatively, if backward compatibility is needed for existing records, keep ref_id: z.string().optional() in the schema.

🔎 Recommended fix: Remove the commented line
 export const personalDataSchema = z.object({
 	...NameDescriptionMixin,
-	// ref_id: z.string().optional().default(''),
 	category: z.string(),
 	retention: z.string(),
 	deletion_policy: z.string(),
 	is_sensitive: z.boolean().optional(),
 	processing: z.string(),
 	assets: z.string().uuid().optional().array().optional()
 });

And remove the TextField in PersonalDataForm.svelte (see separate comment).

frontend/src/lib/components/Forms/ModelForm/PersonalDataForm.svelte (1)

28-35: Critical: Form field references non-existent schema field.

This TextField references field="ref_id", but personalDataSchema no longer defines ref_id (it's commented out in schemas.ts line 869). This will cause form validation and submission issues because superforms requires fields to be defined in the schema.

Given the PR objective to "remove useless ref_id," this entire TextField component should be removed rather than conditionally hidden. The hidden logic hidden={!initialData.ref_id} won't work as intended since the field can't be validated or submitted without being in the schema.

🔎 Recommended fix: Remove the TextField entirely
-<TextField
-	{form}
-	field="ref_id"
-	label={m.refId()}
-	cacheLock={cacheLocks['ref_id']}
-	bind:cachedValue={formDataCache['ref_id']}
-	hidden={!initialData.ref_id}
-/>
 <AutocompleteSelect
 	{form}
 	field="category"
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 503c07e and df44d3f.

📒 Files selected for processing (2)
  • frontend/src/lib/components/Forms/ModelForm/PersonalDataForm.svelte
  • frontend/src/lib/utils/schemas.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: enterprise-startup-functional-test (3.12)
  • GitHub Check: startup-functional-test (3.12)
  • GitHub Check: build_enterprise_frontend
  • GitHub Check: enterprise-startup-docker-compose-test
  • GitHub Check: startup-docker-compose-test
  • GitHub Check: build_community_frontend
  • GitHub Check: Analyze (python)

Copy link
Collaborator

@nas-tabchiche nas-tabchiche left a comment

Choose a reason for hiding this comment

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

Let's just delete the ref_id field in PersonalDataForm.svelte and its associated schema instead of hiding/commenting it out.

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.

3 participants