Skip to content

SHARED-2644: Downgrade node auth context-cancel errors#2086

Open
dvashchuk wants to merge 2 commits into
mainfrom
fix/node-auth-context-cancel-log
Open

SHARED-2644: Downgrade node auth context-cancel errors#2086
dvashchuk wants to merge 2 commits into
mainfrom
fix/node-auth-context-cancel-log

Conversation

@dvashchuk
Copy link
Copy Markdown

@dvashchuk dvashchuk commented May 23, 2026

Why is this change necessary?

AuthenticateJWT logged ERROR for Node validation failed when IsNodePubKeyTrusted returned context cancellation/deadline. These are expected during shutdown/timeout paths and should not page as high-severity failures.

What is changing?

  • in pkg/nodeauth/jwt/node_jwt_authenticator.go, log WARN (not ERROR) when provider error is context cancellation/deadline
  • keep ERROR for real provider failures
  • add tests asserting ERROR for non-context provider errors and WARN for context-cancelled provider errors

How was this tested?

  • go test -timeout 30s -run TestNodeJWTAuthenticator ./pkg/nodeauth/jwt/...

Copilot AI review requested due to automatic review settings May 23, 2026 08:52
@dvashchuk dvashchuk requested a review from a team as a code owner May 23, 2026 08:52
@github-actions
Copy link
Copy Markdown

👋 dvashchuk, thanks for creating this pull request!

To help reviewers, please consider creating future PRs as drafts first. This allows you to self-review and make any final changes before notifying the team.

Once you're ready, you can mark it as "Ready for review" to request feedback. Thanks!

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 23, 2026

📊 API Diff Results

No changes detected for module github.com/smartcontractkit/chainlink-common

View full report

Copy link
Copy Markdown
Contributor

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

Adjusts NodeJWTAuthenticator.AuthenticateJWT logging to avoid emitting ERROR logs for expected shutdown / request-cancellation scenarios when IsNodePubKeyTrusted returns context.Canceled or context.DeadlineExceeded, while preserving ERROR logs for real provider failures.

Changes:

  • Downgrade log level from ERROR to WARN when IsNodePubKeyTrusted fails due to context cancellation/deadline.
  • Add tests asserting log level behavior for provider errors vs context cancellation.
  • Introduce a minimal slog.Handler to capture log records in tests.

Reviewed changes

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

File Description
pkg/nodeauth/jwt/node_jwt_authenticator.go Downgrades logging to WARN for context-canceled/deadline errors from the provider.
pkg/nodeauth/jwt/node_jwt_authenticator_test.go Adds log-capture handler and new tests verifying log levels for provider error vs context cancellation.

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

"error", err,
)
if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {
v.logger.Warn("Node validation skipped: context cancelled",
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Addressed: message now reads "Node validation skipped: context canceled or deadline exceeded" (covers both).

Comment thread pkg/nodeauth/jwt/node_jwt_authenticator.go
Comment on lines +469 to +470
func (h *captureHandler) WithAttrs([]slog.Attr) slog.Handler { return h }
func (h *captureHandler) WithGroup(string) slog.Handler { return h }
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Addressed: WithAttrs and WithGroup now return a new captureHandler with merged attrs/groups (not the same handler). See lines in node_jwt_authenticator_test.go.

@dvashchuk dvashchuk changed the title fix(nodeauth): downgrade ERROR to WARN for context-cancelled IsNodePubKeyTrusted SHARED-2644: Downgrade node auth context-cancel errors May 23, 2026
@dvashchuk dvashchuk force-pushed the fix/node-auth-context-cancel-log branch from f95c05b to f35e344 Compare May 23, 2026 11:20
@dvashchuk dvashchuk closed this May 23, 2026
@dvashchuk dvashchuk reopened this May 23, 2026
@dvashchuk dvashchuk force-pushed the fix/node-auth-context-cancel-log branch 2 times, most recently from 11eadf3 to 7b7656a Compare May 23, 2026 21:06
@dvashchuk dvashchuk requested a review from a team as a code owner May 23, 2026 21:06
@dvashchuk dvashchuk force-pushed the fix/node-auth-context-cancel-log branch 4 times, most recently from 5a7b58c to c225417 Compare May 25, 2026 03:12
Comment thread pkg/beholder/durable_event_store.go Outdated
…thenticator

When IsNodePubKeyTrusted returns context.Canceled or
context.DeadlineExceeded, log at WARN instead of ERROR. These are
expected transient conditions (caller-initiated cancellation or slow
upstream) and should not fire alerts.

Adds tests for both Canceled and DeadlineExceeded paths, and a
well-behaved captureHandler for slog assertions.

Ticket: SHARED-2644
@dvashchuk dvashchuk force-pushed the fix/node-auth-context-cancel-log branch from e466681 to 0314cd8 Compare June 1, 2026 14:16
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.

3 participants