Skip to content

Conversation

@pranavxc
Copy link
Member

@pranavxc pranavxc commented Mar 5, 2025

Change Summary

Re - https://discord.com/channels/661905455894888490/1346768933562224661

Change type

  • feat: (new feature for the user, not a new feature for build script)
  • fix: (bug fix for the user, not a fix to a build script)
  • docs: (changes to the documentation)
  • style: (formatting, missing semi colons, etc; no production code change)
  • refactor: (refactoring production code, eg. renaming a variable)
  • test: (adding missing tests, refactoring tests; no production code change)
  • chore: (updating grunt tasks etc; no production code change)

Test/ Verification

Provide summary of changes.

Additional information / screenshots (optional)

Anything for maintainers to be made aware of

@pranavxc pranavxc requested a review from mertmit March 5, 2025 11:55
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 5, 2025

📝 Walkthrough

Walkthrough

This PR updates two files. In the configuration source module, a new variable mergedConfig is introduced to hold the merged result from the deepMerge function with an additional filter on the searchPath property. In the utilities module, the deepMerge function is modified to initialize target properties based on the source type (array or object) instead of a generic object. These changes adjust the control flow for configuration merging and ensure more accurate handling of data types.

Changes

File Change Summary
packages/nocodb/src/models/Source.ts Introduced mergedConfig to store the merged result of configuration objects. Added a conditional check to validate and potentially remove searchPath, and updated the return statement accordingly.
packages/nocodb/src/utils/dataUtils.ts Modified the deepMerge function to initialize target[key] as an empty array when source[key] is an array, and as an object otherwise.

Sequence Diagram(s)

sequenceDiagram
    participant C as Caller
    participant S as Source.getConfig
    participant D as deepMerge

    C->>S: Call getConfig
    S->>D: Call deepMerge(integrationConfig, configPartial)
    D-->>S: Return merged configuration
    S->>S: Validate mergedConfig.searchPath (set to undefined if invalid)
    S-->>C: Return mergedConfig
Loading

Suggested reviewers

  • mertmit
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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)
packages/nocodb/src/utils/dataUtils.ts (1)

79-81: Excellent improvement for proper type initialization in the deepMerge function.

The change properly initializes nested target objects based on the source data type (array or object). This prevents potential issues when merging arrays into objects and vice versa, ensuring more accurate deep merging behavior.

For even more robust implementation, consider adding a check for the null case:

- if (!target[key]) target[key] = Array.isArray(source[key]) ? [] : {};
+ if (!target[key]) target[key] = Array.isArray(source[key]) ? [] : (source[key] === null ? null : {});
packages/nocodb/src/models/Source.ts (1)

378-385: Consider explicit handling for different empty searchPath scenarios.

The current implementation treats empty strings and empty arrays the same way by setting them to undefined. This is generally fine, but it might be worth considering if these cases should be handled differently.

You could consider making the handling more explicit if there are different expectations for empty strings vs. empty arrays:

if (
  (!Array.isArray(mergedConfig.searchPath) &&
    typeof mergedConfig.searchPath !== 'string') ||
- !mergedConfig.searchPath?.length
+ (Array.isArray(mergedConfig.searchPath) && mergedConfig.searchPath.length === 0) ||
+ (typeof mergedConfig.searchPath === 'string' && mergedConfig.searchPath.length === 0)
) {
  mergedConfig = { ...mergedConfig, searchPath: undefined };
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2d0fcb4 and dfb46a8.

📒 Files selected for processing (2)
  • packages/nocodb/src/models/Source.ts (1 hunks)
  • packages/nocodb/src/utils/dataUtils.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: release-docker / buildx
  • GitHub Check: pre-build-for-playwright / playwright
  • GitHub Check: unit-tests-pg
  • GitHub Check: unit-tests
🔇 Additional comments (3)
packages/nocodb/src/models/Source.ts (3)

370-376: Improved code organization with a named variable.

Storing the result of deepMerge in a named variable mergedConfig enhances code readability and maintainability. This also allows for further manipulation of the merged configuration.


387-387: LGTM!

The updated return statement is aligned with the previous changes, now returning the properly validated merged configuration.


378-385:

✅ Verification successful

Great fix for handling invalid searchPath values.

The added validation properly handles cases where searchPath is missing, invalid, or empty by explicitly setting it to undefined. This prevents potential issues downstream when using this configuration.

Let's verify our handling of various searchPath values to ensure all edge cases are covered:


🏁 Script executed:

#!/bin/bash
# Check how searchPath is handled in the codebase

# Find other places in the codebase that use searchPath
echo "Searching for searchPath usage in the codebase..."
rg "searchPath" --context 5 | grep -v "Source.ts"

# Check for any existing value validations
echo "Checking for existing searchPath validation in the codebase..."
rg "searchPath.*(!|\?|isArray|typeof)" --context 3

Length of output: 90340


SearchPath validation confirmed across the codebase.
The changes in Source.ts properly reset an invalid or empty searchPath to undefined, which is in line with similar validations in other parts of the code (for example, in EditBase.vue and CreateBase.vue). This consistency helps prevent downstream issues when the value is used. No further modifications appear necessary.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2025

Uffizzi Preview deployment-61566 was deleted.

@pranavxc pranavxc merged commit ec3523a into develop Mar 5, 2025
23 checks passed
@pranavxc pranavxc deleted the nc-fix/pg-missing-searchPath-issue branch March 5, 2025 12:18
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