Skip to content

Facts/os: avoid blank linux os.version on rolling releases#834

Open
asger-weirsoee wants to merge 1 commit intogoauthentik:mainfrom
asger-weirsoee:bugfix/parse_os_version
Open

Facts/os: avoid blank linux os.version on rolling releases#834
asger-weirsoee wants to merge 1 commit intogoauthentik:mainfrom
asger-weirsoee:bugfix/parse_os_version

Conversation

@asger-weirsoee
Copy link
Copy Markdown

INFO[1802] Starting user/group fetch                     logger=component.directory pid=999545 target=ak-sysd
DEBU[1802] dispatching event                             id=directory logger=sysd pid=999545 target=ak-sysd topic=sysd.directory.fetched
DEBU[1802] dispatching event                             logger=sysd pid=999545 target=ak-sysd topic=sysd.directory.fetched
INFO[1802] Finished user/group fetch                     logger=component.directory next=30m0s pid=999545 target=ak-sysd
DEBU[1829] Starting facts gathering...                   logger=component.device pid=999545 target=ak-sysd
DEBU[1829] Gathering...                                  area=disk logger=component.device pid=999545 target=ak-sysd
DEBU[1829] Gathering...                                  area=hardware logger=component.device pid=999545 target=ak-sysd
DEBU[1829] Gathering...                                  area=network logger=component.device pid=999545 target=ak-sysd
DEBU[1829] Gathering...                                  area=os logger=component.device pid=999545 target=ak-sysd
DEBU[1829] Gathering...                                  area=process logger=component.device pid=999545 target=ak-sysd
DEBU[1829] Gathering...                                  area=user logger=component.device pid=999545 target=ak-sysd
DEBU[1829] Gathering...                                  area=group logger=component.device pid=999545 target=ak-sysd
DEBU[1829] Gathering...                                  area=vendor logger=component.device pid=999545 target=ak-sysd
DEBU[1829] Finished facts gathering                      logger=component.device pid=999545 target=ak-sysd
WARN[1829] failed to checkin                             error="failed to checkin: HTTP Error '400 Bad Request' during request 'POST /api/v3/endpoints/agents/connectors/check_in/': \"{\"os\":{\"version\":[\"This field may not be blank.\"]}}\" (Request ID 'ec97fc27c5b34fafbaee4f123b6d1c34')" logger=component.device pid=999545 target=ak-sysd
DEBU[1831] Starting a new transaction [writable: false]  logger=storage.state
DEBU[1831] Starting a new transaction [writable: false] successfully  logger=storage.state

According to os-release(5)

PRETTY_NAME=

A pretty operating system name in a format suitable for presentation to the user. May or may not contain a release code name or OS version of some kind, as suitable. If not set, a default of "PRETTY_NAME="Linux"" may be used

So, version is not guaranteed to be present in PRETTY_NAME, and parsing a version from it can legitimately result in an empty value on rolling-release distributions.

This means that the entire check-in request is rejected because os.version is present but blank

The endpoint requires a value if version is sent, so the agent should either:

  • send a valid version
  • omit version entirely when no value can be derived, since the field i optional

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 27, 2026

Codecov Report

❌ Patch coverage is 71.15385% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 38.08%. Comparing base (7d32797) to head (1a64312).

Files with missing lines Patch % Lines
pkg/platform/facts/os/os_linux.go 71.15% 11 Missing and 4 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main     #834       +/-   ##
===========================================
+ Coverage   16.58%   38.08%   +21.50%     
===========================================
  Files         204      203        -1     
  Lines        6827     6968      +141     
===========================================
+ Hits         1132     2654     +1522     
+ Misses       5553     3980     -1573     
- Partials      142      334      +192     
Flag Coverage Δ
go-e2e 42.45% <72.72%> (?)
go-macos-15 13.47% <ø> (-0.37%) ⬇️
go-ubuntu-24.04 13.76% <72.72%> (+0.37%) ⬆️
go-ubuntu-24.04-arm 13.27% <71.15%> (+0.39%) ⬆️
go-windows-2025 12.76% <ø> (-0.36%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

1 participant