Skip to content

GH-54957: [Python][Parquet] Translate C++ ParquetException in metadata accessors to prevent process abort - #55244

Open
ishaaaan17 wants to merge 1 commit into
apache:mainfrom
ishaaaan17:fix/parquet-metadata-exception-handling
Open

ishaaaan17 wants to merge 1 commit into
apache:mainfrom
ishaaaan17:fix/parquet-metadata-exception-handling

Conversation

@ishaaaan17

@ishaaaan17 ishaaaan17 commented Oct 25, 2026 •

Copy link
Copy Markdown

rationale for this change

in the Cython declarations (libparquet.pxd and _parquet.pxd), the C++ metadata accessors did not have except +. when a damaged Parquet footer makes C++ throw parquet::ParquetException, the exception is not handled, it crosses the C boundary and triggers std::terminate (the interpreter is aborted), instead of raising a Python OSError.

what changes are included in this PR?

  • added except + to the metadata accessor declarations in python/pyarrow/includes/libparquet.pxd.
  • added except * to the inline init methods in python/pyarrow/_parquet.pxd.
  • added the regression test test_damaged_metadata_raises_exception_not_abort in python/pyarrow/tests/parquet/test_metadata.py.

are these changes tested?

yes, i added a regression test in python/pyarrow/tests/parquet/test_metadata.py.

are there any user-facing changes?

no API changes. accessing corrupted metadata now raises OSError, and does not crash the process.

This PR contains a "Critical Fix".
prevents the process from aborting (std::terminate) on damaged Parquet footers.

was ai used for this PR?

PR code and description written by:

  • human
  • ai

reviewed before submission by:

  • human
  • ai
  • not reviewed

i used an llm assistant to find the missing Cython except + declarations and to structure the regression test.

…etadata accessors to prevent process abort

Add 'except +' to C++ declarations of statistics(), geo_statistics(), crypto_metadata(), ColumnChunk(), RowGroup(), WriteTo(), and CFileMetaData_Make in libparquet.pxd, and 'except *' to RowGroupMetaData.init and ColumnChunkMetaData.init in _parquet.pxd.

Without 'except +', Cython does not generate C++ try/catch wrappers around these methods. When a damaged Parquet footer causes C++ to throw parquet::ParquetException, it triggers std::terminate across the C boundary, aborting the Python interpreter instead of translating into a Python exception.
@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #54957 has been automatically assigned in GitHub to PR creator.

@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #54957 has been automatically assigned in GitHub to PR creator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant