Skip to content

Conversation

@anilsahoo20
Copy link
Contributor

@anilsahoo20 anilsahoo20 commented Nov 25, 2025

Summary by CodeRabbit

  • Bug Fixes
    • Improved parameter validation in the debugger to prevent invalid argument configurations and provide clearer error messages when parameters are incorrectly positioned after default values.

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

@coderabbitai
Copy link

coderabbitai bot commented Nov 25, 2025

Walkthrough

Adds a new helper function filter_params_by_default() to the debugger module that validates function arguments and truncates parameter lists at the first default value occurrence. This function is integrated into the initialize_target_for_function and initialize_target_for_trigger handlers to enforce validation that no arguments follow a default value.

Changes

Cohort / File(s) Change Summary
Debugger parameter validation
web/pgadmin/tools/debugger/__init__.py
Added filter_params_by_default() helper function to validate and truncate function parameter lists at first default value. Updated initialize_target_for_function and initialize_target_for_trigger handlers to parse request data, invoke validation, and handle errors with localized messaging. Replaces direct json.loads() usage with parsed parameter validation workflow.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

  • Validation logic correctness: Ensure filter_params_by_default() properly identifies default values and truncates the parameter list as intended
  • Error handling paths: Verify error messages are localized and that internal server errors are returned appropriately on validation failure
  • Integration consistency: Confirm both handler functions (initialize_target_for_function and initialize_target_for_trigger) apply the validation consistently and assign results correctly back to de_inst.function_data['args_value']

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: adding validation to handle default value arguments in debugger function/procedure parameters, as shown by the new filter_params_by_default function and its integration.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8c44740 and 3a79964.

📒 Files selected for processing (1)
  • web/pgadmin/tools/debugger/__init__.py (2 hunks)
🔇 Additional comments (1)
web/pgadmin/tools/debugger/__init__.py (1)

906-914: Helper integration in initialize_target looks correct.

Decoding request.data once, running it through filter_params_by_default, bailing out on an error message, and only then assigning de_inst.function_data['args_value'] is clean and keeps the validation centralised. No further changes needed here.


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

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

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8c153be and 9bf9711.

📒 Files selected for processing (1)
  • web/pgadmin/tools/debugger/templates/debugger/sql/get_function_debug_info.sql (1 hunks)
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: run-feature-tests-pg (18)
  • GitHub Check: run-feature-tests-pg (16)
  • GitHub Check: run-feature-tests-pg (17)
  • GitHub Check: run-feature-tests-pg (15)
  • GitHub Check: run-feature-tests-pg (13)
  • GitHub Check: run-feature-tests-pg (14)
🔇 Additional comments (1)
web/pgadmin/tools/debugger/templates/debugger/sql/get_function_debug_info.sql (1)

51-73: Request verification of the fix scope against issue #9036.

The changes address type-cast cleanup, but without seeing the original issue or test cases, it's unclear whether the current implementation handles all necessary scenarios correctly. Specifically:

  • What types of default argument values were causing the original bug?
  • Are there existing tests that validate this fix against regression?
  • Does the affected PostgreSQL version(s) produce any unexpected output formats from pg_get_expr?

Please confirm: (1) the root cause of #9036, (2) which PostgreSQL versions are in scope, and (3) whether test coverage exists for edge cases like quoted strings or complex types.

Copy link

@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)
web/pgadmin/tools/debugger/__init__.py (1)

788-817: Add documentation explaining the validation rules.

The filter_params_by_default function enforces an important constraint but lacks documentation explaining:

  • What SQL/PL/pgSQL rule is being enforced (no arguments after defaults)
  • What the expected input format is for params_list and default_value_str
  • Examples of valid and invalid parameter combinations

Consider adding a comprehensive docstring:

def filter_params_by_default(params_list, default_value_str):
    """
    Validate and truncate params_list to enforce SQL parameter rules.
    
    SQL/PL/pgSQL functions don't allow providing arguments after a default
    value is used. This function finds the first parameter using its default
    value and ensures no subsequent parameters are provided.
    
    Args:
        params_list: List of parameter dicts with 'value' keys
                     e.g., [{'value': '10'}, {'value': ''}, {'value': ''}]
        default_value_str: Comma-separated string of default values
                          e.g., "'default1','default2','default3'"
    
    Returns:
        tuple: (filtered_params_list, error_message)
               - On success: (truncated list up to first default, None)
               - On error: (None, error message string)
    
    Example:
        # Function has 3 params with defaults ['x', 'y', 'z']
        # User provides ['1', 'y', ''] - ERROR: provided arg after default
        # User provides ['1', 'y'] - OK: truncate to ['1', 'y']
        # User provides ['1'] - OK: keep as ['1']
    """
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9bf9711 and b07eafa.

📒 Files selected for processing (2)
  • docs/en_US/release_notes_9_11.rst (1 hunks)
  • web/pgadmin/tools/debugger/__init__.py (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
web/pgadmin/tools/debugger/__init__.py (2)
web/regression/javascript/fake_gettext.js (1)
  • gettext (40-42)
web/pgadmin/utils/ajax.py (1)
  • internal_server_error (98-105)
🪛 Ruff (0.14.7)
web/pgadmin/tools/debugger/__init__.py

912-912: Do not catch blind exception: Exception

(BLE001)

⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: run-python-tests-pg (windows-latest, 13)
  • GitHub Check: run-python-tests-pg (windows-latest, 15)
  • GitHub Check: run-python-tests-pg (windows-latest, 16)
  • GitHub Check: run-python-tests-pg (windows-latest, 14)
  • GitHub Check: run-feature-tests-pg (17)
  • GitHub Check: run-feature-tests-pg (15)
  • GitHub Check: run-feature-tests-pg (14)
  • GitHub Check: run-feature-tests-pg (18)
  • GitHub Check: run-feature-tests-pg (13)
  • GitHub Check: run-feature-tests-pg (16)
🔇 Additional comments (1)
docs/en_US/release_notes_9_11.rst (1)

42-42: LGTM!

The release notes entry is clear and follows the established format.

@khushboovashi khushboovashi merged commit 55a332b into pgadmin-org:master Dec 8, 2025
37 checks passed
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