Skip to content

1182: Add custom exceptions for unsupported XPT format and enhance error handling in XPTReader#1644

Merged
SFJohnson24 merged 9 commits intomainfrom
1182-SAS-V8-Transport-File-Error-Message
Mar 10, 2026
Merged

1182: Add custom exceptions for unsupported XPT format and enhance error handling in XPTReader#1644
SFJohnson24 merged 9 commits intomainfrom
1182-SAS-V8-Transport-File-Error-Message

Conversation

@alexfurmenkov
Copy link
Collaborator

No description provided.

@alexfurmenkov alexfurmenkov changed the title Add custom exceptions for unsupported XPT format and enhance error handling in XPTReader 1182: Add custom exceptions for unsupported XPT format and enhance error handling in XPTReader Feb 27, 2026
@alexfurmenkov alexfurmenkov linked an issue Mar 1, 2026 that may be closed by this pull request
…into 1182-SAS-V8-Transport-File-Error-Message
Copy link
Collaborator

@SFJohnson24 SFJohnson24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comment

Copy link
Collaborator

@RamilCDISC RamilCDISC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR adds only exception for unsupported xpt format but does not actually verifies the version of the xpt. The AC requires that the version of xpt is validated and if its not v5 then custom exception should be thrown. I tried with ae.xpt file (v8 version from the zip attached in ticket). The validation executed fully and did not throw any exception.

@alexfurmenkov
Copy link
Collaborator Author

alexfurmenkov commented Mar 5, 2026

@RamilCDISC, I execute with ae.xpt file (v8 version from the zip attached in ticket) and set -l error .
image

@alexfurmenkov
Copy link
Collaborator Author

When using pd.read_sas, the argument format="xport" indicates that we expect a SAS Transport V5 file. Therefore, if there is a version mismatch while reading the SAS file, the error "Header record is not an XPORT file." is raised.

At the moment, we catch all possible errors during read_sas. In the next commit, I will narrow this down to catching only this specific error: "Header record is not an XPORT file."

I can also add unit tests for attempts to read SAS files of different versions (V5 and V8). If you have examples of test data for other versions as well, please share them and I will include them in the tests.

@RamilCDISC
Copy link
Collaborator

@alexfurmenkov The v8 xpt test data is attached in the connected issue. You can take from there and v5 xpt are available in the test resources. i have verified, the engine does show error.

What we can decide on is do we want for such a file skip execution for all rules or show RULE EXECUTION ERROR in the status column of the report. @SFJohnson24 What do you think?

@SFJohnson24
Copy link
Collaborator

@RamilCDISC I think skipping will take more of a lift. If a user tries to submit bad data--the execution should be halted until they format in v5.

@RamilCDISC
Copy link
Collaborator

@SFJohnson24 Thanks for your response. @alexfurmenkov the PR is then correct. Are you still planning to narrow down the error catch as you mentioned in your previous comment, os I should perform final validation and add closing comments.

@alexfurmenkov
Copy link
Collaborator Author

Hi @RamilCDISC
I have finished the planned changes. Please feel free to review.

Copy link
Collaborator

@RamilCDISC RamilCDISC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR adds exception and error handling to xpt_reader class. The error highlights that only v5 transport files are supported only. The validation was done by:

  1. Reviewing the PR for nay unwanted code or comments.
  2. Reviewing the PR logic in accordance with AC.
  3. Ensuring all unit and regression testing pass.
  4. Ensuring new tests form updated behavior are added.
  5. Running manual validation using CLI with valid xpt file.
  6. Running manual validation using CLI with unsupported xpt file.
  7. Ensuring proper error messages in report.
  8. Ensuring study based rules still work fine when used with unsupported xpt version.

Copy link
Collaborator

@SFJohnson24 SFJohnson24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR correctly addresses issue with incorrect XPT formatting

@SFJohnson24 SFJohnson24 merged commit 2b641bb into main Mar 10, 2026
12 checks passed
@SFJohnson24 SFJohnson24 deleted the 1182-SAS-V8-Transport-File-Error-Message branch March 10, 2026 19:38
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.

SAS V8 Transport File Error Message

3 participants