Skip to content

fix: narrow exception in Content-Length header lookup from Exception to AttributeError - #3918

Open
Quratulain-bilal wants to merge 3 commits into
github:mainfrom
Quratulain-bilal:fix/content-length-narrow-exception
Open

Quratulain-bilal wants to merge 3 commits into
github:mainfrom
Quratulain-bilal:fix/content-length-narrow-exception

Conversation

@Quratulain-bilal

Copy link
Copy Markdown
Contributor

Problem

Bare except Exception would swallow MemoryError, RecursionError, etc.

Fix

Narrow to AttributeError which is the only realistic failure from getheader().

Testing

  • Verified Content-Length header is read correctly

  • Verified missing header is handled gracefully

…to AttributeError

Bare 'except Exception' would swallow MemoryError, RecursionError,
etc. The only realistic failure from getheader() is AttributeError.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Narrows Content-Length lookup error handling to avoid swallowing critical exceptions.

Changes:

  • Catches only AttributeError from getheader().
Show a summary per file
File Description
src/specify_cli/workflows/_commands.py Narrows header lookup exception handling.

Review details

Tip

Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread src/specify_cli/workflows/_commands.py

@mnriem mnriem left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please address Copilot feedback

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale because it has had no activity for 60 days. It will be closed in 30 days unless there is a substantive update. If you intend to continue, please describe the current status, address or acknowledge outstanding feedback, and confirm whether the branch can be updated and the change remains ready for review. A comment that only states that the pull request is "still relevant" does not provide enough context for maintainers.

@github-actions github-actions Bot added the stale label Oct 12, 2026
- test_attribute_error_from_getheader_is_caught: AttributeError from
  getheader() is caught and reading continues
- test_runtime_error_from_getheader_propagates: RuntimeError now
  propagates (was swallowed by bare except Exception)

Assisted-by: GitHub Copilot (autonomous)
…rrow-exception

# Conflicts:
#	tests/test_workflows.py

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The test diff duplicates 60 existing tests and places new CLI coverage outside the required modular suite.

1 open finding
1 resolved since last review

🧠 Review effort: Balanced

Comment thread tests/test_workflows.py
assert stat.S_IMODE(registry.registry_path.stat().st_mode) == 0o644
assert not list(registry.workflows_dir.glob("*.tmp"))

def test_update_mixed_targets_does_not_claim_all_up_to_date(self, project_dir, monkeypatch):
@mnriem

mnriem commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator

Please address Copilot feedback and test & lint errors

This branch has not been deployed

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants