Skip to content

Hoftix/desintation specification mismatch#1701

Merged
Ishankoradia merged 2 commits into
mainfrom
hoftix/desintation-specification-mismatch
Feb 25, 2026
Merged

Hoftix/desintation specification mismatch#1701
Ishankoradia merged 2 commits into
mainfrom
hoftix/desintation-specification-mismatch

Conversation

@Ishankoradia

@Ishankoradia Ishankoradia commented Feb 25, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Bug Fixes
    • Fixed destination specification endpoint selection to correctly use different sources when creating vs. editing destinations.
    • Enhanced configuration form rendering with improved default field selection and nested field handling for better form initialization.

@coderabbitai

coderabbitai Bot commented Feb 25, 2026

Copy link
Copy Markdown

Walkthrough

Modified destination form configuration handling to dynamically select specification endpoints based on edit state (warehouse present) versus creation state. Enhanced connector config input with improved discriminator detection logic across schema traversal, oneOf processing, and form field prefilling to support multiple discriminator formats.

Changes

Cohort / File(s) Summary
Form Specification Endpoint Selection
src/components/Destinations/DestinationForm.tsx
Added conditional logic to select different API endpoints: uses airbyte/destinations/{destinationId}/specifications when editing, and airbyte/destination_definitions/{id}/specifications when creating. Updated ConnectorConfigInput data initialization to prioritize data.connectionSpecification when available.
Discriminator Detection & Schema Processing
src/helpers/ConnectorConfigInput.tsx
Enhanced traverseSpecs to derive discriminator enum values from const, enum[0], default, or parent title. Improved oneOf branch processing with common field detection and discriminator prioritization. Added discriminator detection within object-valued fields during rendering and form field prefilling using heuristic-based matching for parent names and common discriminator patterns.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title contains a typo ('desintation' instead of 'destination') and lacks clarity about the main change, making it unclear what issue is being addressed. Correct the typo to 'destination' and provide more specificity about the nature of the mismatch being fixed (e.g., 'Fix specification endpoint selection for destination form editing').
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
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 docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch hoftix/desintation-specification-mismatch

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.

@sentry

sentry Bot commented Feb 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.34%. Comparing base (6b4c5ae) to head (410f6db).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1701      +/-   ##
==========================================
+ Coverage   75.33%   75.34%   +0.01%     
==========================================
  Files         107      107              
  Lines        7962     7966       +4     
  Branches     1866     1929      +63     
==========================================
+ Hits         5998     6002       +4     
+ Misses       1927     1840      -87     
- Partials       37      124      +87     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/components/Destinations/DestinationForm.tsx`:
- Around line 136-139: Guard against data being undefined before accessing
connectionSpecification: in the block that constructs ConnectorConfigInput in
DestinationForm (the line creating new ConnectorConfigInput('destination',
data.connectionSpecification || data)), check that data is defined first and
either early-return / show loading/error or pass a safe fallback; e.g., use
optional chaining or a fallback value when calling new ConnectorConfigInput
(e.g., data?.connectionSpecification ?? data ?? {}) or add an if (!data) { /*
handle missing data */ } before constructing ConnectorConfigInput to prevent
reading connectionSpecification on undefined.

In `@src/helpers/ConnectorConfigInput.tsx`:
- Around line 139-154: The lookup for the discriminator field can throw when a
oneOf branch lacks a properties object; change the access to use safe optional
chaining so the discriminator retrieval is tolerant (e.g., use
data?.properties?.[exclude[0]]), keep the existing fallback logic that checks
discriminatorField?.const, discriminatorField?.enum?.[0],
discriminatorField?.default and then data?.title, and push to dropdownEnums only
when enumValue is set; update the reference in the block that currently defines
discriminatorField and enumValue to use the safe access pattern to avoid runtime
errors.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 6b4c5ae and 410f6db.

📒 Files selected for processing (2)
  • src/components/Destinations/DestinationForm.tsx
  • src/helpers/ConnectorConfigInput.tsx

Comment on lines +136 to +139
const connectorConfigInput = new ConnectorConfigInput(
'destination',
data.connectionSpecification || data
);

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 | 🟠 Major

Guard data before reading connectionSpecification.

At Line 138, data.connectionSpecification will throw if the GET returns undefined (e.g., unauthorized path from httpGet). Add a null guard before constructing ConnectorConfigInput.

💡 Proposed fix
-          const connectorConfigInput = new ConnectorConfigInput(
-            'destination',
-            data.connectionSpecification || data
-          );
+          if (!data) {
+            errorToast('Unable to load destination specification', [], globalContext);
+            return;
+          }
+
+          const specification = data.connectionSpecification ?? data;
+          const connectorConfigInput = new ConnectorConfigInput('destination', specification);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/Destinations/DestinationForm.tsx` around lines 136 - 139,
Guard against data being undefined before accessing connectionSpecification: in
the block that constructs ConnectorConfigInput in DestinationForm (the line
creating new ConnectorConfigInput('destination', data.connectionSpecification ||
data)), check that data is defined first and either early-return / show
loading/error or pass a safe fallback; e.g., use optional chaining or a fallback
value when calling new ConnectorConfigInput (e.g., data?.connectionSpecification
?? data ?? {}) or add an if (!data) { /* handle missing data */ } before
constructing ConnectorConfigInput to prevent reading connectionSpecification on
undefined.

Comment on lines +139 to +154
const discriminatorField = data?.properties[exclude[0]];
let enumValue = discriminatorField?.const || discriminatorField?.enum?.[0];

// Handle new format where discriminator might be the title or default value
if (!enumValue && discriminatorField?.default) {
enumValue = discriminatorField.default;
}

// For new object-type format, extract from title or use parent data title
if (!enumValue && data?.title) {
enumValue = data.title.toLowerCase();
}

if (enumValue) {
dropdownEnums.push(enumValue);
}

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 | 🟠 Major

Use safe optional access for properties in discriminator lookup.

At Line 139, data?.properties[exclude[0]] can throw when a oneOf branch has no properties (title/default-only variants). That prevents the new fallback logic from executing.

💡 Proposed fix
-      if (exclude[0] in data?.properties) {
-        const discriminatorField = data?.properties[exclude[0]];
-        let enumValue = discriminatorField?.const || discriminatorField?.enum?.[0];
-
-        // Handle new format where discriminator might be the title or default value
-        if (!enumValue && discriminatorField?.default) {
-          enumValue = discriminatorField.default;
-        }
-
-        // For new object-type format, extract from title or use parent data title
-        if (!enumValue && data?.title) {
-          enumValue = data.title.toLowerCase();
-        }
-
-        if (enumValue) {
-          dropdownEnums.push(enumValue);
-        }
-      }
+      const discriminatorField = data?.properties?.[exclude[0]];
+      let enumValue =
+        discriminatorField?.const ??
+        discriminatorField?.enum?.[0] ??
+        discriminatorField?.default;
+
+      // For object-type format, extract from title when explicit discriminator is absent
+      if (!enumValue && data?.title) {
+        enumValue = data.title.toLowerCase();
+      }
+
+      if (enumValue) {
+        dropdownEnums.push(enumValue);
+      }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/helpers/ConnectorConfigInput.tsx` around lines 139 - 154, The lookup for
the discriminator field can throw when a oneOf branch lacks a properties object;
change the access to use safe optional chaining so the discriminator retrieval
is tolerant (e.g., use data?.properties?.[exclude[0]]), keep the existing
fallback logic that checks discriminatorField?.const,
discriminatorField?.enum?.[0], discriminatorField?.default and then data?.title,
and push to dropdownEnums only when enumValue is set; update the reference in
the block that currently defines discriminatorField and enumValue to use the
safe access pattern to avoid runtime errors.

);
let data;

if (warehouse) {

@himanshudube97 himanshudube97 Feb 25, 2026

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.

can you add -> if (warehouse && warehouse?.destinationId)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It will fail in the Destinations.tsx component itself ?

we are doing this there

setWarehouse({
airbyteWorkspaceId: w_house.airbyte_destination.workspaceId,
airbyteDockerRepository: w_house.airbyte_docker_repository,
tag: w_house.airbyte_docker_image_tag,
destinationId: w_house.airbyte_destination.destinationId,
destinationDefinitionId: w_house.airbyte_destination.destinationDefinitionId,
name: w_house.name,
wtype: w_house.wtype,
icon: w_house.airbyte_destination.icon,
connectionConfiguration: w_house.airbyte_destination.connectionConfiguration,
ssl: w_house.ssl,
} as Warehouse);

so this would fail w_house.airbyte_destination.destinationId

should i add it here also ?

@Ishankoradia Ishankoradia merged commit 86651f0 into main Feb 25, 2026
6 checks passed
@Ishankoradia Ishankoradia deleted the hoftix/desintation-specification-mismatch branch February 25, 2026 10:53
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