Skip to content

Refactor 404 handling - #880

Merged
decyjphr merged 1 commit into
main-enterprisefrom
879-fix-archive-plugin
Sep 26, 2025
Merged

Refactor 404 handling#880
decyjphr merged 1 commit into
main-enterprisefrom
879-fix-archive-plugin

Conversation

@decyjphr

Copy link
Copy Markdown
Collaborator

This pull request makes small improvements to the Archive plugin by simplifying error handling and making the code more robust when accessing repository properties.

Copilot AI review requested due to automatic review settings September 26, 2025 16:06
@decyjphr decyjphr linked an issue Sep 26, 2025 that may be closed by this pull request

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

This PR refactors error handling in the Archive plugin by simplifying 404 error handling logic and adding optional chaining for safer repository property access.

  • Simplifies 404 error handling by removing the additional condition check
  • Adds optional chaining (?.) when accessing repository properties to prevent potential null/undefined errors

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread lib/plugins/archive.js
} catch (error) {
if (error.status === 404 && !this.getDesiredArchiveState()) {
if (error.status === 404) {
return null

Copilot AI Sep 26, 2025

Copy link

Choose a reason for hiding this comment

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

Removing the !this.getDesiredArchiveState() condition changes the behavior for 404 errors. This now returns null for all 404 errors regardless of the desired archive state, which may not be the intended behavior. Consider documenting why this condition was removed or verify this change doesn't break existing functionality.

Suggested change
return null
if (!this.getDesiredArchiveState()) {
return null
}

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

When the repo is not existing, whether to archive or unArchive doesn't make much of a difference. We cannot throw an Error and stop further processing.

@decyjphr
decyjphr merged commit 2d244e4 into main-enterprise Sep 26, 2025
5 checks passed
@decyjphr
decyjphr deleted the 879-fix-archive-plugin branch September 26, 2025 16:08
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.

Archive plugin returns 404 and break when repo doesn't exist

2 participants