Skip to content

fix: rename countDistinct to countdistinct in allowed functions #211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

catalyst17
Copy link
Contributor

@catalyst17 catalyst17 commented May 26, 2025

TL;DR

We check for allowed lowercased functions so had to change the countDistinct function name to lowercase countdistinct in the allowed functions map.

What changed?

Modified the allowedFunctions map in internal/common/utils.go to use lowercase countdistinct instead of the previously camelCase countDistinct. This ensures consistent naming convention for function names.

How to test?

  1. Verify that any code using the countdistinct function continues to work properly
  2. Check that any API calls or queries using this function name are properly recognized
  3. Run existing tests to ensure no regressions

Why make this change?

This change standardizes the function naming convention to use all lowercase for function names in the allowedFunctions map. This improves consistency with other function names and likely fixes case-sensitivity issues when these function names are used in queries or API calls.

Summary by CodeRabbit

  • Bug Fixes
    • Improved function name validation to recognize only lowercase "countdistinct" as an allowed function, ensuring consistent and accurate query validation.

Copy link

coderabbitai bot commented May 26, 2025

Walkthrough

The change updates the function name key in the allowed functions map from "countDistinct" (camel case) to "countdistinct" (all lowercase) within the query validation logic. This ensures that only the lowercase version is recognized as valid, affecting how function names are checked during query validation.

Changes

File(s) Change Summary
internal/common/utils.go Changed allowed function key from "countDistinct" to "countdistinct".

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ValidateQuery
    participant allowedFunctions

    User->>ValidateQuery: Submit query with function name
    ValidateQuery->>allowedFunctions: Check if function name (e.g., "countdistinct") is allowed
    allowedFunctions-->>ValidateQuery: Return true if name matches lowercase key
    ValidateQuery-->>User: Accept or reject query based on validation
Loading

📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between dace8a7 and 7fa05a2.

📒 Files selected for processing (1)
  • internal/common/utils.go (1 hunks)
🔇 Additional comments (1)
internal/common/utils.go (1)

28-28:

✅ Verification successful

Good consistency improvement, but verify broader impact.

The change to lowercase is good for consistency with other function names in the map. However, since ValidateQuery already converts function names to lowercase before checking (line 79), this change may have minimal functional impact on query validation itself.

Please run the following script to ensure no other code directly accesses the old key name:


🏁 Script executed:

#!/bin/bash
# Description: Search for direct usage of the old "countDistinct" key in the codebase
# Expected: No direct map access with the old key name should be found

echo "Searching for direct usage of 'countDistinct' key..."
rg -A 3 -B 3 'allowedFunctions\["countDistinct"\]'

echo "Searching for any remaining references to 'countDistinct'..."
rg -A 2 -B 2 'countDistinct' --type go

echo "Searching for test files that might reference the old function name..."
fd -e go -e test | xargs rg -l 'countDistinct'

Length of output: 547


Approve: No remaining countDistinct references detected

The lowercase key standardizes allowedFunctions and aligns with ValidateQuery’s strings.ToLower logic. A repository-wide search found no direct usages or test references to "countDistinct", so this change is safe to merge.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in 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 Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@catalyst17 catalyst17 requested a review from a team May 26, 2025 11:30
@catalyst17 catalyst17 marked this pull request as ready for review May 26, 2025 11:31
@catalyst17 catalyst17 merged commit b95d5e4 into main May 26, 2025
6 checks passed
@catalyst17 catalyst17 deleted the fix_rename_countDistinct_to_countdistinct_in_allowed_functions branch May 26, 2025 12:21
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