Skip to content

Conversation

@mihow
Copy link
Collaborator

@mihow mihow commented Dec 6, 2025

Summary

The data_source_regex field in the Station / Deployment form often gets saved with the string "null". This PR ensures the frontend keeps nulls as null rather than converting it to a string. A future enhancement could be to post/patch JSON data instead of form data -- for fields other than the image field. We also need to ensure "clearing" the field works so that PATCH sends null instead of omitting the field from the request.

Important: It's unclear when this happens! We are not able to manually reproduce the issue, but it happens regularly. I have updated all existing deployments in the production database that contained "null" in this field (48 in total).

Screenshots

image

Summary by CodeRabbit

  • Bug Fixes
    • Prevented "null" strings from being added to form submissions by serializing nulls as empty values.
    • Stopped null values from being included in URL query parameters, avoiding unwanted "null" entries in searches.
    • Made filtering logic treat null like an absent value to avoid showing or applying null filters.
    • Allowed certain deployment fields to be empty (null) to better represent missing data.

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

Copilot AI review requested due to automatic review settings December 6, 2025 00:35
@netlify
Copy link

netlify bot commented Dec 6, 2025

Deploy Preview for antenna-preview ready!

Name Link
🔨 Latest commit 28d1e30
🔍 Latest deploy log https://app.netlify.com/projects/antenna-preview/deploys/693385e692eb3c0008ba6f84
😎 Deploy Preview https://deploy-preview-1074--antenna-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 74 (🟢 up 36 from production)
Accessibility: 89 (🟢 up 9 from production)
Best Practices: 92 (🔴 down 8 from production)
SEO: 100 (🟢 up 8 from production)
PWA: 80 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 6, 2025

Warning

Rate limit exceeded

@mihow has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 11 minutes and 5 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 8ae8617 and 28d1e30.

📒 Files selected for processing (1)
  • ui/src/pages/deployment-details/deployment-details-form/section-source-images/section-source-images.tsx (1 hunks)

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Updated utilities and a model: functions now treat null like undefined when serializing or adding query params; two deployment model fields and their getters were changed to allow null values.

Changes

Cohort / File(s) Summary
Null handling in UI utilities
ui/src/components/filtering/utils.ts, ui/src/utils/getAppRoute.ts
Tightened conditions to exclude both null and undefined before returning string values or setting searchParams, preventing null from being stringified or appended to the query.
FormData serialization
ui/src/data-services/hooks/deployments/utils.ts
convertToFormData now converts null to an empty string (instead of "null") and continues to skip undefined, changing how nullable fields are appended to FormData.
Deployment model nullability
ui/src/data-services/models/deployment-details.ts
DeploymentFieldValues properties dataSourceSubdir and dataSourceRegex now allow `string

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Focus review on:
    • ui/src/data-services/models/deployment-details.ts for API/typing implications where getters now return string | null.
    • Call sites of convertToFormData to ensure empty-string semantics for null are acceptable.
    • Places that consume query params or boolean-to-string outputs to confirm null exclusion doesn't break behavior.

Poem

🐇 I hopped through fields both undefined and null,

turned tangled "null" to blank with a careful pull.
No stray strings now on the data trail,
Clean queries hop along without fail.
A tiny rabbit's tidy data tale. 🥕✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request has no description provided, missing all required template sections including summary, changes, issues, testing instructions, and deployment notes. Add a comprehensive description following the repository template, including a summary of changes, list of modified files, related issue references, testing instructions, and any deployment considerations.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: fixing how null values are handled in form serialization to prevent 'null' strings from appearing in the station update form.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes an issue where the string "null" was appearing in the station update form by adding null checks alongside existing undefined checks in three utility functions.

Key Changes:

  • Added && value !== null conditions to prevent null values from being converted to the string "null"
  • Applied the fix consistently across URL parameter handling, form data conversion, and boolean-to-string conversion functions

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
ui/src/utils/getAppRoute.ts Adds null check when setting URL search parameters to prevent "null" strings in filters
ui/src/data-services/hooks/deployments/utils.ts Adds null check when appending deployment field values to FormData to prevent "null" strings in form submissions
ui/src/components/filtering/utils.ts Adds null check in boolean-to-string conversion to return empty string instead of "null"

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

)
Object.entries(filters).forEach(([name, value]) => {
if (value !== undefined) {
if (value !== undefined && value !== null) {
Copy link

Copilot AI Dec 6, 2025

Choose a reason for hiding this comment

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

The type definition for filters specifies Partial<Record<FilterType, string | undefined>> which doesn't include null. If null values are possible at runtime (as this fix suggests), the type should be updated to Partial<Record<FilterType, string | undefined | null>> to accurately reflect the possible values and improve type safety.

Copilot uses AI. Check for mistakes.
}
}

export const booleanToString = (value?: boolean) =>
Copy link

Copilot AI Dec 6, 2025

Choose a reason for hiding this comment

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

The parameter type is value?: boolean which doesn't include null. If null values are possible at runtime (as this fix suggests), the type should be updated to value?: boolean | null to accurately reflect the possible values and improve type safety.

Suggested change
export const booleanToString = (value?: boolean) =>
export const booleanToString = (value?: boolean | null) =>

Copilot uses AI. Check for mistakes.
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

🧹 Nitpick comments (2)
ui/src/utils/getAppRoute.ts (1)

29-31: Consider aligning filters type with new null handling

The extra value !== null guard is good for avoiding "null" in the query string. If null is now a legitimate “no value” signal for filters, you may want to reflect that in the type:

  • Change filters?: Partial<Record<FilterType, string | undefined>> to allow string | null | undefined, or
  • Drop the null check if null should never appear in filters.

Not blocking, but aligning the type with runtime behavior will make this intent clearer and catch misuses at compile time.

ui/src/components/filtering/utils.ts (1)

15-16: Update booleanToString parameter type to match null handling

The added value !== null check correctly prevents null from being stringified and aligns with the rest of the PR. To keep the type signature in sync with this behavior, consider widening the parameter type, e.g.:

  • export const booleanToString = (value?: boolean | null) => ...
    or
  • export const booleanToString = (value: boolean | null | undefined) => ...

so that callers and the type system both acknowledge null as an expected input.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f899482 and 9f952ad.

📒 Files selected for processing (3)
  • ui/src/components/filtering/utils.ts (1 hunks)
  • ui/src/data-services/hooks/deployments/utils.ts (1 hunks)
  • ui/src/utils/getAppRoute.ts (1 hunks)
⏰ 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). (4)
  • GitHub Check: Upload results
  • GitHub Check: Redirect rules
  • GitHub Check: Header rules
  • GitHub Check: Pages changed
🔇 Additional comments (1)
ui/src/data-services/hooks/deployments/utils.ts (1)

17-19: Null guard correctly prevents "null" from being sent in form data

The added value !== null check here is consistent with treating null as "no value" and avoids stringifying it, while still allowing valid falsy values like 0 or false to be appended.

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

🧹 Nitpick comments (2)
ui/src/data-services/models/deployment-details.ts (2)

71-73: Consider normalizing undefined to null in dataSourceSubdir

Depending on how ServerDeploymentDetails is shaped, this._deployment.data_source_subdir might be undefined when absent. Since the getter’s return type is string | null, you could normalize at the boundary to avoid ever returning undefined:

-  get dataSourceSubdir(): string | null {
-    return this._deployment.data_source_subdir
-  }
+  get dataSourceSubdir(): string | null {
+    return this._deployment.data_source_subdir ?? null
+  }

This keeps the public API aligned with the annotated type and consistently treats “missing” as null.


75-77: Apply the same undefined→null normalization for dataSourceRegex

For symmetry with dataSourceSubdir and to avoid returning undefined from a string | null getter, you can also coalesce here:

-  get dataSourceRegex(): string | null {
-    return this._deployment.data_source_regex
-  }
+  get dataSourceRegex(): string | null {
+    return this._deployment.data_source_regex ?? null
+  }

This keeps the null-handling semantics consistent across both fields.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9f952ad and 8ae8617.

📒 Files selected for processing (2)
  • ui/src/data-services/hooks/deployments/utils.ts (1 hunks)
  • ui/src/data-services/models/deployment-details.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • ui/src/data-services/hooks/deployments/utils.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). (3)
  • GitHub Check: Redirect rules
  • GitHub Check: Header rules
  • GitHub Check: Pages changed
🔇 Additional comments (1)
ui/src/data-services/models/deployment-details.ts (1)

14-15: Nullable data source fields look correct

Allowing dataSourceSubdir and dataSourceRegex to be string | null (while still optional) matches the intent of supporting real null values from the backend/UI and should help avoid accidental 'null' stringification down the line. No issues from a typing perspective here.

@mihow mihow requested a review from annavik December 6, 2025 01:09
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