Skip to content

Conversation

@Fdawgs
Copy link
Member

@Fdawgs Fdawgs commented Nov 27, 2025

The fastifyAuth function was mutating the opts parameter passed by the caller when setting the default relation. This could cause unexpected side effects for users who reuse the options object.

This change creates a new pluginOptions object with the resolved defaultRelation property instead of modifying the original input.

Checklist

@Fdawgs Fdawgs requested a review from Copilot November 27, 2025 10:39
Copilot finished reviewing on behalf of Fdawgs November 27, 2025 10:40
Copy link

Copilot AI left a comment

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 fixes a bug where the fastifyAuth function was mutating the opts parameter when setting the default relation. The fix ensures that plugin options objects can be safely reused without unexpected side effects.

Key changes:

  • Replaced direct mutation of opts.defaultRelation with creation of a new pluginOptions object
  • Added test coverage to verify that the original opts parameter remains unchanged

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
auth.js Creates new pluginOptions object instead of mutating input opts parameter
test/auth.test.js Adds test to ensure opts parameter is not mutated during plugin registration

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

@Fdawgs Fdawgs requested a review from a team November 27, 2025 13:01
Copy link
Contributor

@is2ei is2ei left a comment

Choose a reason for hiding this comment

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

LGTM!

@Fdawgs Fdawgs merged commit 7a9528d into main Nov 28, 2025
17 checks passed
@Fdawgs Fdawgs deleted the fix/opts-mutation branch November 28, 2025 10:06
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.

4 participants