Skip to content

fix(sources): drop empty reader_options before submit (#1648)#1705

Open
SarthakB11 wants to merge 2 commits into
DalgoT4D:mainfrom
SarthakB11:fix/1648-reader-options-empty-string
Open

fix(sources): drop empty reader_options before submit (#1648)#1705
SarthakB11 wants to merge 2 commits into
DalgoT4D:mainfrom
SarthakB11:fix/1648-reader-options-empty-string

Conversation

@SarthakB11
Copy link
Copy Markdown

@SarthakB11 SarthakB11 commented Apr 11, 2026

Fixes #1648.

Symptom

When a user adds an Excel (or other File-type) source in Dalgo without typing anything into the `reader_options` field, form submission fails with:

Error: Failed to check the source connection: Field 'reader_options' is not valid JSON object. https://www.json.org/

The documented workaround on the issue is to manually type `{}` into the field.

Cause

Airbyte's File source declares `reader_options` as a JSON-encoded string field with no default. react-hook-form serializes an untouched input as `''`, which the Dalgo backend then tries to parse as JSON and rejects.

Fix

Extend `cleanConfig()` in `src/components/Sources/SourceForm.tsx` with the same strip-on-empty pattern already used for `start_date`: if `reader_options` comes through as an empty string, delete it from the payload before sending, so the backend falls back to its own default (equivalent to `{}`).

```diff

  • // Remove reader_options if it's an empty string.
  • // In Airbyte's File/Excel source, reader_options is a JSON-encoded string
  • // field; the backend rejects "" with "Field reader_options is not valid
  • // JSON object" (see issue Issue in adding excel sheet as a source in dalgo #1648). Dropping the empty value lets the
  • // backend fall back to its default (equivalent to {}).
  • if (cleaned.reader_options === '') {
  •  delete cleaned.reader_options;
    
  • }
    ```

`cleanConfig` is called on both the check-connection WebSocket payload (`onSubmit`) and the create/update HTTP payload (`handleSaveSource`), so both paths are covered.

Scope

  • Single file, 10 inserted lines.
  • No tests added — the existing `Sources/tests/` tests are form-level integration tests rather than unit tests on `cleanConfig`, and I wanted to keep this PR focused on the minimal fix. Happy to add one if you'd like (e.g., extending `CreateSourceForm.test.tsx` with a case that asserts `reader_options: ''` is absent from the submitted payload).
  • Doesn't address other JSON-as-string fields on other Airbyte connectors; only the one reported in Issue in adding excel sheet as a source in dalgo #1648. Can file a follow-up issue for a more general solution if helpful.

Verification

  • `npx prettier --check src/components/Sources/SourceForm.tsx` — passes.
  • Code change is a literal string comparison plus an object-property delete, matching the existing `start_date` pattern two lines above.

Summary by CodeRabbit

  • Bug Fixes
    • Improved form handling to omit empty configuration fields (e.g., empty reader options and start date) from submissions and saves, reducing invalid/blank data persisted.
  • Documentation
    • Minor formatting and clarity updates across README, issue templates, contributor docs, and code of conduct.
  • Tests
    • Added tests verifying the form-cleaning behavior and non-mutating input handling.

When adding an Excel (or other File-based) source in Dalgo, submitting
the form without typing anything into reader_options produced:

  Error: Failed to check the source connection: Field 'reader_options'
  is not valid JSON object.

Airbyte's File source declares reader_options as a JSON-encoded string
field with no default; react-hook-form therefore serialized the empty
input as '' which the Dalgo backend then tried to parse as JSON and
rejected. The documented workaround was to manually type '{}'.

This patch extends cleanConfig() with the same strip-on-empty pattern
already used for start_date: if reader_options comes through as an
empty string, drop it from the payload so the backend falls back to
its own default.

Fixes DalgoT4D#1648
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 11, 2026

@SarthakB11 is attempting to deploy a commit to the support-9965's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 11, 2026

Walkthrough

Moved cleanConfig to a top-level exported function and extended it to also remove reader_options when it is an empty string; payloads built for both websocket (onSubmit) and HTTP persist (handleSaveSource) now omit empty reader_options.

Changes

Cohort / File(s) Summary
Source form logic & tests
src/components/Sources/SourceForm.tsx, src/components/Sources/__tests__/cleanConfig.test.ts
Exported cleanConfig(config) as a top-level pure function and made it remove reader_options when it's ''; added tests covering removal of reader_options and start_date, immutability, and passthrough fields.
Issue templates & repo docs
.github/ISSUE_TEMPLATE/bug_report.md, .github/ISSUE_TEMPLATE/c4gt.md, .github/ISSUE_TEMPLATE/feature_request.md, .github/ISSUE_TEMPLATE/task.md, CODE_OF_CONDUCT.md, README.md
Whitespace, YAML/Markdown quoting, and list-formatting cleanups in multiple repo documentation and issue templates.
Build / CI / config files
next.config.js, jest.config.ts, tsconfig.json, cypress/support/component-index.html
Minor formatting and non-functional refactors: CSP header logic reformatted, trailing commas/JSON formatting fixed, HTML tag casing/closing normalized.
Sentry configs
sentry.client.config.ts, sentry.edge.config.ts, sentry.server.config.ts
Normalized string quoting and minor whitespace adjustments in Sentry configuration imports/initialization.
Styling
src/components/Notifications/Notifications.module.css
Re-indented CSS rules and added trailing newline; no selector/property changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • Ishankoradia
  • himanshudube97
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR includes numerous out-of-scope formatting/whitespace changes unrelated to #1648: issue template cleanup, CODE_OF_CONDUCT.md bullet formatting, README.md edits, HTML doctype changes, trailing comma additions, and Sentry import quote style changes. Revert non-functional changes to issue templates, documentation, and config files; keep only the core fix in SourceForm.tsx and its corresponding test file.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: moving the cleanConfig function and extending it to drop empty reader_options, which directly addresses the linked issue.
Linked Issues check ✅ Passed The PR fulfills the requirement from #1648 by implementing logic to omit empty reader_options from the payload, allowing the backend to apply its default value.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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
Copy Markdown

@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.

🧹 Nitpick comments (1)
src/components/Sources/SourceForm.tsx (1)

286-309: Add a small regression test for cleanConfig behavior.

Given this was a production bug, please add a focused test that asserts reader_options: '' is removed while valid non-empty values remain unchanged.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/Sources/SourceForm.tsx` around lines 286 - 309, Add a focused
unit test for the cleanConfig helper to prevent regressions: import cleanConfig
from SourceForm, then assert that when called with { reader_options: '' } the
returned object does not have reader_options, while { reader_options:
'{"foo":1}' } is preserved unchanged; also include assertions that start_date
values of '', null, and undefined are removed but valid start_date strings
remain. Use the project's Jest/React Testing setup and give the test a clear
name like "cleanConfig removes empty reader_options and empty start_date but
preserves valid values".
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/components/Sources/SourceForm.tsx`:
- Around line 286-309: Add a focused unit test for the cleanConfig helper to
prevent regressions: import cleanConfig from SourceForm, then assert that when
called with { reader_options: '' } the returned object does not have
reader_options, while { reader_options: '{"foo":1}' } is preserved unchanged;
also include assertions that start_date values of '', null, and undefined are
removed but valid start_date strings remain. Use the project's Jest/React
Testing setup and give the test a clear name like "cleanConfig removes empty
reader_options and empty start_date but preserves valid values".

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 568fe147-b43b-4b11-bfe9-e689c1b3031c

📥 Commits

Reviewing files that changed from the base of the PR and between cfce3aa and ec33244.

📒 Files selected for processing (1)
  • src/components/Sources/SourceForm.tsx

Move cleanConfig out of the SourceForm component body to module
scope since it's a pure function with no state deps. Export it
for direct testing.

8 test cases covering reader_options strip, start_date strip
(empty/null/undefined), valid-value preservation, input
immutability, and passthrough of unrelated fields.
Copy link
Copy Markdown

@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: 3

🧹 Nitpick comments (1)
src/components/Sources/SourceForm.tsx (1)

55-56: Harden empty-check for whitespace-only reader_options.

Consider treating trimmed-empty strings as empty too, to avoid accidental " " submissions causing the same backend rejection.

♻️ Suggested patch
-  if (cleaned.reader_options === '') {
+  if (
+    typeof cleaned.reader_options === 'string' &&
+    cleaned.reader_options.trim() === ''
+  ) {
     delete cleaned.reader_options;
   }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/Sources/SourceForm.tsx` around lines 55 - 56, The empty-check
for reader_options should treat whitespace-only strings as empty; update the
condition around cleaned.reader_options in SourceForm.tsx (the block that
currently reads "if (cleaned.reader_options === '') { delete
cleaned.reader_options; }") to first confirm it's a string and then check
trimmed value (e.g., use cleaned.reader_options.trim() === '') so
whitespace-only values are deleted as well; also ensure you guard against
null/undefined before calling trim.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/ISSUE_TEMPLATE/bug_report.md:
- Around line 34-37: Normalize example values for the template fields "Device",
"OS", "Browser", and "Version" to use spaced, more readable forms (e.g., change
"iPhone6" to "iPhone 6", "iOS8.1" to "iOS 8.1", and "safari" to "Safari") so the
examples are consistent and clearer; update the example text for the "Device",
"OS", "Browser", and "Version" lines accordingly and keep capitalization
consistent.

In `@README.md`:
- Line 60: Update the README sentence that currently reads "The env varibales
will be picked up from the .env file during the yarn build stage. This will copy
all the env variables starting with NEXT*PUBLIC* (that get embedd into the
javascript code). The env varibales starting without NEXT*PUBLIC* will be picked
up during run time." by correcting the three typos: change both occurrences of
"varibales" to "variables" and change "embedd" to "embedded" so the sentence
uses "variables" and "embedded" consistently.

In `@src/components/Notifications/Notifications.module.css`:
- Around line 11-12: In Notifications.module.css remove the redundant duplicate
declaration of border-bottom (the second "border-bottom: 15px solid `#fff`;") so
only a single border-bottom rule remains; edit the CSS in
Notifications.module.css to delete the duplicate line associated with the
border-bottom property.

---

Nitpick comments:
In `@src/components/Sources/SourceForm.tsx`:
- Around line 55-56: The empty-check for reader_options should treat
whitespace-only strings as empty; update the condition around
cleaned.reader_options in SourceForm.tsx (the block that currently reads "if
(cleaned.reader_options === '') { delete cleaned.reader_options; }") to first
confirm it's a string and then check trimmed value (e.g., use
cleaned.reader_options.trim() === '') so whitespace-only values are deleted as
well; also ensure you guard against null/undefined before calling trim.
🪄 Autofix (Beta)

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

Run ID: 79c06cca-f3d8-48e1-a378-f580435380db

📥 Commits

Reviewing files that changed from the base of the PR and between ec33244 and c60ab5a.

📒 Files selected for processing (16)
  • .github/ISSUE_TEMPLATE/bug_report.md
  • .github/ISSUE_TEMPLATE/c4gt.md
  • .github/ISSUE_TEMPLATE/feature_request.md
  • .github/ISSUE_TEMPLATE/task.md
  • CODE_OF_CONDUCT.md
  • README.md
  • cypress/support/component-index.html
  • jest.config.ts
  • next.config.js
  • sentry.client.config.ts
  • sentry.edge.config.ts
  • sentry.server.config.ts
  • src/components/Notifications/Notifications.module.css
  • src/components/Sources/SourceForm.tsx
  • src/components/Sources/__tests__/cleanConfig.test.ts
  • tsconfig.json
💤 Files with no reviewable changes (2)
  • .github/ISSUE_TEMPLATE/feature_request.md
  • .github/ISSUE_TEMPLATE/task.md
✅ Files skipped from review due to trivial changes (6)
  • tsconfig.json
  • sentry.client.config.ts
  • sentry.edge.config.ts
  • jest.config.ts
  • sentry.server.config.ts
  • cypress/support/component-index.html

Comment on lines +34 to +37
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Normalize example device/OS wording for consistency.

Minor docs quality nit: examples like iPhone6 / iOS8.1 are less readable than spaced forms.

✏️ Suggested wording tweak
-- Device: [e.g. iPhone6]
-- OS: [e.g. iOS8.1]
+- Device: [e.g. iPhone 6]
+- OS: [e.g. iOS 8.1]
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
- Device: [e.g. iPhone 6]
- OS: [e.g. iOS 8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
🧰 Tools
🪛 LanguageTool

[grammar] ~34-~34: Ensure spelling is correct
Context: ...following information):** - Device: [e.g. iPhone6] - OS: [e.g. iOS8.1] - Browser [e.g. st...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/ISSUE_TEMPLATE/bug_report.md around lines 34 - 37, Normalize example
values for the template fields "Device", "OS", "Browser", and "Version" to use
spaced, more readable forms (e.g., change "iPhone6" to "iPhone 6", "iOS8.1" to
"iOS 8.1", and "safari" to "Safari") so the examples are consistent and clearer;
update the example text for the "Device", "OS", "Browser", and "Version" lines
accordingly and keep capitalization consistent.

Comment thread README.md

The env varibales will be picked up from the .env file during the yarn build stage. This will copy all the env variables starting with NEXT_PUBLIC_ (that get embedd into the javascript code). The env varibales starting without NEXT_PUBLIC_ will be picked up during run time.
Run the script:
The env varibales will be picked up from the .env file during the yarn build stage. This will copy all the env variables starting with NEXT*PUBLIC* (that get embedd into the javascript code). The env varibales starting without NEXT*PUBLIC* will be picked up during run time.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix spelling errors in documentation.

The documentation contains three spelling errors:

  • "varibales" should be "variables" (appears twice)
  • "embedd" should be "embedded"
📝 Proposed fix for spelling errors
-The env varibales will be picked up from the .env file during the yarn build stage. This will copy all the env variables starting with NEXT*PUBLIC* (that get embedd into the javascript code). The env varibales starting without NEXT*PUBLIC* will be picked up during run time.
+The env variables will be picked up from the .env file during the yarn build stage. This will copy all the env variables starting with NEXT*PUBLIC* (that get embedded into the javascript code). The env variables starting without NEXT*PUBLIC* will be picked up during run time.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
The env varibales will be picked up from the .env file during the yarn build stage. This will copy all the env variables starting with NEXT*PUBLIC* (that get embedd into the javascript code). The env varibales starting without NEXT*PUBLIC* will be picked up during run time.
The env variables will be picked up from the .env file during the yarn build stage. This will copy all the env variables starting with NEXT*PUBLIC* (that get embedded into the javascript code). The env variables starting without NEXT*PUBLIC* will be picked up during run time.
🧰 Tools
🪛 LanguageTool

[grammar] ~60-~60: Ensure spelling is correct
Context: ...Step 2: Build the Docker image The env varibales will be picked up from the .env file du...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)


[grammar] ~60-~60: Ensure spelling is correct
Context: ...es starting with NEXTPUBLIC (that get embedd into the javascript code). The env vari...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)


[grammar] ~60-~60: Ensure spelling is correct
Context: ...bedd into the javascript code). The env varibales starting without NEXTPUBLIC will be p...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@README.md` at line 60, Update the README sentence that currently reads "The
env varibales will be picked up from the .env file during the yarn build stage.
This will copy all the env variables starting with NEXT*PUBLIC* (that get embedd
into the javascript code). The env varibales starting without NEXT*PUBLIC* will
be picked up during run time." by correcting the three typos: change both
occurrences of "varibales" to "variables" and change "embedd" to "embedded" so
the sentence uses "variables" and "embedded" consistently.

Comment on lines +11 to +12
border-bottom: 15px solid #fff;
border-bottom: 15px solid #fff;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Remove the duplicate border-bottom declaration.

Line 12 duplicates the border-bottom property from line 11. The second declaration is redundant and should be removed.

🧹 Proposed fix
   border-bottom: 15px solid `#fff`;
-  border-bottom: 15px solid `#fff`;
   border-left: 15px solid transparent;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
border-bottom: 15px solid #fff;
border-bottom: 15px solid #fff;
border-bottom: 15px solid `#fff`;
border-left: 15px solid transparent;
🧰 Tools
🪛 Stylelint (17.6.0)

[error] 11-11: Unexpected duplicate "border-bottom" (declaration-block-no-duplicate-properties)

(declaration-block-no-duplicate-properties)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/Notifications/Notifications.module.css` around lines 11 - 12,
In Notifications.module.css remove the redundant duplicate declaration of
border-bottom (the second "border-bottom: 15px solid `#fff`;") so only a single
border-bottom rule remains; edit the CSS in Notifications.module.css to delete
the duplicate line associated with the border-bottom property.

@SarthakB11
Copy link
Copy Markdown
Author

@himanshudube97 @Ishankoradia — friendly bump when one of you has a moment. Small fix for #1648 (DAL-661); CI green and CodeRabbit's nits are on unrelated formatter-touched files. Happy to iterate.

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.

Issue in adding excel sheet as a source in dalgo

1 participant