Skip to content

Fix DataFrame Error Handling for Non-existent Columns #625 #737

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sambhavnoobcoder
Copy link


name: Pull Request
about: Create a pull request to contribute to the project
title: 'Fix DataFrame Error Handling for Non-existent Columns'
labels: 'bug,enhancement'
assignees: ''

Related Issue
Fixes #625

Description of Changes
This PR enhances DataFrame error handling when users attempt to access non-existent columns.

Key improvements:

  1. Added a validate_dataframe_operation function that checks for column existence before operations
  2. Enhanced error messages with available column names and helpful suggestions
  3. Made error handling consistent between preview and published modes
  4. Improved code organization by refactoring complex methods into smaller, focused helpers
  5. Added comprehensive tests for validation functionality
  6. Created example scripts demonstrating both the error scenario and proper fixes

This ensures users receive helpful, actionable error messages instead of cryptic errors when accessing non-existent columns.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • New example
  • Test improvement

Testing
I've created a dedicated test suite in tests/test_dataframe_operations.py with 4 test cases covering:

  • Valid column validation
  • Invalid column access detection
  • Type checking
  • Empty DataFrame handling

Additionally, I've created example scripts in the examples directory:

  • bug_simulation.py: Demonstrates both the original bug and the improved error handling
  • dataframe_validation_example.py: Shows proper usage of the validation function
  • simple_validation_test.py: A simple script to directly test the validation

All tests pass and the examples work as expected. Screenshot shows the bug simulation output with clear error messages:

image

image

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.

[BUG][Web browser editor] When open published app via web browser editor, I can see error 'Error executing script : 'value'' and preview is working well
1 participant