goauthentik / goauthentik/authentik

Bug: Runtime values are used as structured log event names or field keys

Open
#22,196 2 comments 0 reactions 0 assignees View on GitHub
bug bug/confirmed good first issue
Dominant language
Python
Stars
25.6k
Forks
2k
Avg merge
1d 1h
Merged PRs (30d)
644

Description

### Describe the bug

# Bug: Runtime values are used as structured log event names or field keys

## Anti-pattern

This report identifies logging calls where dynamic runtime data is used as the log event name or as a structured field key. In structured logging, event names and field keys should be stable schema elements. Runtime-specific data such as IDs, URLs, object names, errors, query labels, or caller-controlled keys should be emitted as field values under stable keys instead of changing the event or key surface.

## Impact on observability platforms

When event names or field keys vary with runtime data, observability backends can see unnecessary cardinality growth in log streams, indexes, facets, labels, and dashboards. This makes queries harder to write, splits one logical event across many names or fields, increases storage and indexing cost, and can reduce the usefulness of alerts and aggregations. When opaque identifiers or shifted key/value pairs become field names, the resulting records are also harder for humans to scan and interpret.

## Affected entrypoints

Commit: `c6b5869b488b07ddd598d1f8066d3d054ae806c0`

Found 10 affected entrypoint(s): 7 message-name entrypoint(s), 3 structured-key entrypoint(s).

- `key` `authentik/sources/kerberos/sync.py:74`
- `key` `authentik/sources/ldap/sync/groups.py:127`
- `key` `authentik/sources/ldap/sync/users.py:88`
- `msg` `authentik/blueprints/v1/importer.py:372`
- `msg` `authentik/events/logs.py:40`
- `msg` `authentik/providers/saml/processors/authn_request_parser.py:71`
- `msg` `authentik/tasks/models.py:143`
- `msg` `authentik/tasks/models.py:146`
- `msg` `authentik/tasks/models.py:149`
- `msg` `authentik/tasks/schedules/scheduler.py:26`

### How to reproduce

Trigger any affected entrypoint listed below and inspect the emitted structured log record.

### Expected behavior

Log event names and structured field keys should remain stable across executions. Runtime-specific data should be emitted as structured field values under fixed, descriptive keys.

### Screenshots

_No response_

### Additional context

_No response_

### Deployment Method

Docker

### Version

c6b5869b488b07ddd598d1f8066d3d054ae806c0

### Relevant log output

```shell

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.