Skip to content

Guard os.listdir in PostProcessInterfaceDetailsList.parse() against missing dir and unrelated files - #54

Merged
Joseph-Ellaway merged 2 commits into
PDBE-8507-interface-table-data-onlyfrom
copilot/fix-code-review-comment-53
May 26, 2026
Merged

Guard os.listdir in PostProcessInterfaceDetailsList.parse() against missing dir and unrelated files#54
Joseph-Ellaway merged 2 commits into
PDBE-8507-interface-table-data-onlyfrom
copilot/fix-code-review-comment-53

Conversation

Copilot AI commented May 26, 2026

Copy link
Copy Markdown
Contributor

PostProcessInterfaceDetailsList.parse() called os.listdir unconditionally, risking FileNotFoundError when no interfaces were generated and inadvertently opening unrelated files in the directory.

Changes

  • Directory existence check — added os.path.isdir guard before os.listdir; logs a warning and returns early if the directory is absent
  • File filtering — restricts iteration to files matching interface_*.{json,json.gz} (driven by self.compressed) plus an os.path.isfile guard to skip subdirectories
  • Empty-set handling — warns and returns early when no matching interface files are found

Mirrors the pattern already established in CompileInterfaceSummaryJSON.parse().

if not os.path.isdir(self.path_interfaces):
    LOGGER.warning(...)
    return

ext = ".json.gz" if self.compressed else ".json"
interface_files = [
    f
    for f in os.listdir(self.path_interfaces)
    if f.startswith("interface_") and f.endswith(ext)
    and os.path.isfile(os.path.join(self.path_interfaces, f))
]

if not interface_files:
    LOGGER.warning(...)
    return

…ror CompileInterfaceSummaryJSON approach

Agent-Logs-Url: https://github.com/PDBe-KB/pisa-analysis/sessions/a5c9fa4a-7b33-452b-8efb-694672b776b3

Co-authored-by: Joseph-Ellaway <69363546+Joseph-Ellaway@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix code based on review comment Guard os.listdir in PostProcessInterfaceDetailsList.parse() against missing dir and unrelated files May 26, 2026
Copilot AI requested a review from Joseph-Ellaway May 26, 2026 12:53
@Joseph-Ellaway
Joseph-Ellaway marked this pull request as ready for review May 26, 2026 13:15
Copilot AI review requested due to automatic review settings May 26, 2026 13:15
@Joseph-Ellaway
Joseph-Ellaway merged commit a8a3df0 into PDBE-8507-interface-table-data-only May 26, 2026
1 check failed
@Joseph-Ellaway
Joseph-Ellaway deleted the copilot/fix-code-review-comment-53 branch May 26, 2026 13:16
Copilot AI removed the request for review from Copilot May 26, 2026 13:41
Joseph-Ellaway added a commit that referenced this pull request Jun 1, 2026
* Interface details page model

Initial commit

* Interface details model

* Missing fields in post-proc models added

* Parser for generating interface details file

* Sort results

* Parser for interface details integrated into run.py

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Guard `os.listdir` in `PostProcessInterfaceDetailsList.parse()` against missing dir and unrelated files (#54)

* Initial plan

* Fix os.listdir usage in PostProcessInterfaceDetailsList.parse() - mirror CompileInterfaceSummaryJSON approach

Agent-Logs-Url: https://github.com/PDBe-KB/pisa-analysis/sessions/a5c9fa4a-7b33-452b-8efb-694672b776b3

Co-authored-by: Joseph-Ellaway <69363546+Joseph-Ellaway@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Joseph-Ellaway <69363546+Joseph-Ellaway@users.noreply.github.com>

* Make interface_auth_asym_id param optional

* Fix linting

* Version bump

* Add rounding of interface metrics

* Increase verbisity during tests

* Unit tests for interface details model/parser

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
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