Skip to content
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

Prevent logging exception due to nil attribute #49134

Merged
merged 1 commit into from
Nov 18, 2024

Conversation

rosstimothy
Copy link
Contributor

The where condition being logged in SearchSession events is nil even though it's not nil, thanks Go, causing additional log spam. This addresses the issue by only passing in the condition if it was populated in the request.

2024-11-18T13:04:02-05:00 DEBU [AUDIT]     SearchSessionEvents from:2024-11-18 05:00:00 +0000 UTC to:2024-11-19 04:59:59.999 +0000 UTC order:1 limit:5000 error:[LogValue panicked
called from runtime.panicwrap (runtime/error.go:355)
called from github.com/gravitational/teleport/api/types.(*WhereExpr).String (<autogenerated>:1)
called from github.com/gravitational/teleport/lib/utils/log.stringerAttr.LogValue (github.com/gravitational/teleport/lib/utils/log/slog_handler.go:662)
called from log/slog.Value.Resolve (log/slog/value.go:512)
called from github.com/gravitational/teleport/lib/utils/log.(*SlogTextHandler).appendAttr (github.com/gravitational/teleport/lib/utils/log/slog_handler.go:140)
(rest of stack elided)
] trace_id:42463c70955f653d0f992286feae738e span_id:a4e9b13d53f8f7d8 events/filelog.go:348

The where condition being logged in SearchSession events is nil
even though it's not nil, thanks Go, causing additional log spam.
This addresses the issue by only passing in the condition if it
was populated in the request.

```bash
2024-11-18T13:04:02-05:00 DEBU [AUDIT]     SearchSessionEvents from:2024-11-18 05:00:00 +0000 UTC to:2024-11-19 04:59:59.999 +0000 UTC order:1 limit:5000 error:[LogValue panicked
called from runtime.panicwrap (runtime/error.go:355)
called from github.com/gravitational/teleport/api/types.(*WhereExpr).String (<autogenerated>:1)
called from github.com/gravitational/teleport/lib/utils/log.stringerAttr.LogValue (github.com/gravitational/teleport/lib/utils/log/slog_handler.go:662)
called from log/slog.Value.Resolve (log/slog/value.go:512)
called from github.com/gravitational/teleport/lib/utils/log.(*SlogTextHandler).appendAttr (github.com/gravitational/teleport/lib/utils/log/slog_handler.go:140)
(rest of stack elided)
] trace_id:42463c70955f653d0f992286feae738e span_id:a4e9b13d53f8f7d8 events/filelog.go:348
```
@rosstimothy rosstimothy added no-changelog Indicates that a PR does not require a changelog entry backport/branch/v17 labels Nov 18, 2024
@github-actions github-actions bot added audit-log Issues related to Teleports Audit Log size/sm labels Nov 18, 2024
@github-actions github-actions bot requested review from camscale and zmb3 November 18, 2024 18:06
@rosstimothy rosstimothy added this pull request to the merge queue Nov 18, 2024
@public-teleport-github-review-bot public-teleport-github-review-bot bot removed the request for review from camscale November 18, 2024 19:38
Merged via the queue into master with commit 12ad8c7 Nov 18, 2024
41 of 42 checks passed
@rosstimothy rosstimothy deleted the tross/fix_filelog_error branch November 18, 2024 19:56
@public-teleport-github-review-bot

@rosstimothy See the table below for backport results.

Branch Result
branch/v17 Create PR

kopiczko pushed a commit that referenced this pull request Nov 19, 2024
The where condition being logged in SearchSession events is nil
even though it's not nil, thanks Go, causing additional log spam.
This addresses the issue by only passing in the condition if it
was populated in the request.

```bash
2024-11-18T13:04:02-05:00 DEBU [AUDIT]     SearchSessionEvents from:2024-11-18 05:00:00 +0000 UTC to:2024-11-19 04:59:59.999 +0000 UTC order:1 limit:5000 error:[LogValue panicked
called from runtime.panicwrap (runtime/error.go:355)
called from github.com/gravitational/teleport/api/types.(*WhereExpr).String (<autogenerated>:1)
called from github.com/gravitational/teleport/lib/utils/log.stringerAttr.LogValue (github.com/gravitational/teleport/lib/utils/log/slog_handler.go:662)
called from log/slog.Value.Resolve (log/slog/value.go:512)
called from github.com/gravitational/teleport/lib/utils/log.(*SlogTextHandler).appendAttr (github.com/gravitational/teleport/lib/utils/log/slog_handler.go:140)
(rest of stack elided)
] trace_id:42463c70955f653d0f992286feae738e span_id:a4e9b13d53f8f7d8 events/filelog.go:348
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
audit-log Issues related to Teleports Audit Log backport/branch/v17 no-changelog Indicates that a PR does not require a changelog entry size/sm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants