Skip to content

Error logging improvement. #114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 22, 2025
Merged

Error logging improvement. #114

merged 1 commit into from
Aug 22, 2025

Conversation

route443
Copy link
Contributor

@route443 route443 commented Aug 19, 2025

  • Implemented unified function for error handling.
  • Each error is assigned its own identifier, generated by using the first 8 chars of the $request_id variable.
  • Added support for JSON log output. This is controlled by the $oidc_log_format variable, which must be set to 'json'.
  • Added support for stack trace output. This is enabled by the $oidc_debug variable, which must have any non-empty value. If this variable is defined, the $internal_error_message variable is overwritten with the text of the last error and returned to the User Agent - so use this only for debugging!

Fixes issue #113

Example:

{"refId":"276072cf:codeExchange.validate","message":"OIDC ID Token validation error: nonce from token (0000) does not match client (1111)","clientIp":"127.0.0.1","host":"localhost:8080","method":"GET","uri":"/_codexch","httpVersion":"1.0","stack":"Error: OIDC ID Token validation error: nonce from token (0000) does not match client ()\n    at validateIdTokenClaims (/tmp/nginx-test-z0FP7gJiCP/openid_connect.js:168)\n    at validateIdToken (/tmp/nginx-test-z0FP7gJiCP/openid_connect.js:127)\n    at native (native)\n"}

Copy link

@Copilot 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 implements unified error handling for the OpenID Connect module with improved logging capabilities and debugging support. The changes introduce error reference IDs, JSON log formatting, and optional stack trace output.

Key changes:

  • Added unified oidcError() function for consistent error handling with reference IDs
  • Converted error handling from simple logging to structured error throwing with try-catch blocks
  • Added configurable JSON log format and debug mode with stack traces

Reviewed Changes

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

File Description
openid_connect.server_conf Added commented debug configuration variable
openid_connect.js Complete error handling refactor with new unified error function and structured exception handling

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

@route443 route443 marked this pull request as ready for review August 21, 2025 16:09
- Implemented unified function for error handling.
- Each error is assigned its own identifier, generated by using the first
8 chars of the $request_id variable.
- Added support for JSON log output. This is controlled by the
$oidc_log_format variable, which must be set to 'json'.
- Added support for stack trace output. This is enabled by the
$oidc_debug variable, which must have any non-empty value.
If this variable is defined, the $internal_error_message variable
is overwritten with the text of the last error and returned to
the User Agent - so use this only for debugging!
@route443 route443 merged commit 24d53f9 into main Aug 22, 2025
1 check passed
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