-
Notifications
You must be signed in to change notification settings - Fork 38
Improve the error handling for opening invalid formatted indexed files #676
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
Merged
yutaro-sakamoto
merged 9 commits into
opensourcecobol:develop
from
yutaro-sakamoto:fix-indexed-file
Jul 18, 2025
Merged
Improve the error handling for opening invalid formatted indexed files #676
yutaro-sakamoto
merged 9 commits into
opensourcecobol:develop
from
yutaro-sakamoto:fix-indexed-file
Jul 18, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Improves error handling for indexed file operations by enforcing a permanent error status on invalid formats and resolves constant value collisions.
- Adds an SQL-based check in
CobolIndexedFile
to detect invalid-format indexed files, returning status 30 on failure - Updates system error constants in
CobolFile
to prevent overlaps with COB_STATUS_* values - Enhances test scripts in
load.at
andmiscellaneous.at
to cover the new error handling behavior
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
tests/run.src/miscellaneous.at | Added a new AT test for opening an invalid-formatted indexed file and verifying status 30 |
tests/cobj-idx.src/load.at | Declared FILE-STATUS in the COBOL test to suppress default messaging and check new behavior |
libcobj/app/src/main/java/jp/osscons/opensourcecobol/libcobj/file/CobolIndexedFile.java | Introduced an existence check for INPUT mode and an SQL select 1 validation, mapping failures to status 30 |
libcobj/app/src/main/java/jp/osscons/opensourcecobol/libcobj/file/CobolFile.java | Reordered and redefined error constants (ENOENT, EBADF, etc.) to avoid collisions with COB_STATUS_* |
Comments suppressed due to low confidence (1)
tests/run.src/miscellaneous.at:2099
- [nitpick] The test creates
invalid-formatted-file
but doesn’t explicitly remove it; consider adding an AT_CLEANUP step to delete this artifact and avoid side effects on subsequent tests.
AT_SETUP([Open an invalid formatted indexed file])
libcobj/app/src/main/java/jp/osscons/opensourcecobol/libcobj/file/CobolIndexedFile.java
Outdated
Show resolved
Hide resolved
libcobj/app/src/main/java/jp/osscons/opensourcecobol/libcobj/file/CobolFile.java
Show resolved
Hide resolved
tsh-hashimoto
approved these changes
Jul 18, 2025
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
このPRの主目的は、無効なフォーマットのINDEXEDファイルを開いたときにファイルステータスを30番に設定することである。
以前までのバージョンでは、無効なフォーマットのINDXEDファイルを開いてもファイルステータスは00番であった。
この改修に付随していくつか別の修正も実施した。
CobolFille.java
定数ENOENTやEBADFに設定される値を、COB_STATUS_*に設定される値と重複しないように変更した。
このPRのために修正する過程で、定数の衝突により不具合が生じることがあったため、ついでにこの変更を実施した。
CobolIndexedFile.java
select 1
を実行して、有効なSQLiteファイルを開いているかを確認するプロセスを追加。失敗時にファイルステータスを30にする設定を追加。load.at
以前のバージョンのテストケースでは、無効なINDEXEDファイルを開く処理があったが、不具合により成功扱いになっていた。
今回の改修により無効なINDEXEDファイルを開くとエラーコードが設定され、FILE STATUSが宣言されていないファイルのためデフォルトのエラーメッセージが表示されるようになった。
FILE STATUSを明示的に宣言することで、デフォルトのエラーメッセージの表示を抑制して、OPENに失敗した場合のエラーハンドリングを適切に設定することで、既存のテストをpassするように変更した。
miscellaneous.at
今回のINDEXEDファイルの修正に対するテスト。