src: handle nameless user @ ProcessMetrics::Update#364
src: handle nameless user @ ProcessMetrics::Update#364santigimeno wants to merge 2 commits intonode-v22.x-nsolid-v5.xfrom
Conversation
WalkthroughUpdates ProcessMetrics::Update() in Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant PM as ProcessMetrics::Update
participant UV as libuv
participant Stor as stor_
PM->>UV: uv_get_process_title(title_buf)
alt success (er == 0)
PM->>PM: title = title_buf
else failure
PM->>PM: leave title empty, continue
end
PM->>UV: uv_os_get_passwd(&pwd)
alt success (er == 0)
rect rgba(200,235,255,0.3)
note right of PM: create OnScopeLeave guard
PM->>PM: user = pwd.username
end
else failure
PM->>PM: leave user empty, no guard
end
PM->>Stor: stor_.title = title
PM->>Stor: stor_.user = user
PM->>PM: continue updating remaining metrics
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/nsolid.cc (2)
214-214: Add an intent-revealing comment for the empty-user fallback.A brief note here will prevent future regressions and clarifies why an empty username is acceptable.
+ // uv_os_get_passwd() may fail (e.g., nameless system user). Leave `user` empty and continue. std::string user;
246-246: Avoid an extra string copy.Move-assign the local into the stored field.
- stor_.user = user; + stor_.user = std::move(user);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/nsolid.cc(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/nsolid.cc (1)
deps/uv/src/uv-common.c (1)
uv_os_free_passwd(132-147)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: coverage-windows
- GitHub Check: test-linux (ubuntu-24.04)
- GitHub Check: test-macOS
- GitHub Check: lint-js-and-md
- GitHub Check: test-linux (ubuntu-24.04-arm)
- GitHub Check: build-tarball
🔇 Additional comments (1)
src/nsolid.cc (1)
235-238: Good: continue metrics when passwd lookup fails; RAII frees pwd safely.This matches the PR objective and avoids an unnecessary early return. The scope guard correctly frees pwd on success.
Please confirm no downstream consumer assumes
stor_.useris non-empty (UI labels, logs, or filters). If any do, they should handle""gracefully.
If nsolid is running as a user without a name (e.g. system user), uv_os_get_passwd may fail. This change ensures ProcessMetrics::Update still fills metrics and does not return early in that case, leaving the user field empty instead of failing the update.
dc4953e to
ff5c452
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/nsolid.cc(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/nsolid.cc (1)
deps/uv/src/uv-common.c (1)
uv_os_free_passwd(132-147)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: test-macOS
- GitHub Check: build-tarball
- GitHub Check: test-linux (ubuntu-24.04-arm)
- GitHub Check: test-linux (ubuntu-24.04)
- GitHub Check: coverage-windows
- GitHub Check: lint-js-and-md
🔇 Additional comments (1)
src/nsolid.cc (1)
241-244: Good: passwd failure no longer aborts metrics; memory is freed conditionallyProceeding when
uv_os_get_passwd()fails and guardinguv_os_free_passwd(&pwd)withOnScopeLeaveonly on success is correct and avoids freeing uninitialized memory. Settinguserto empty is aligned with the PR goal.Please confirm no downstream consumers assume
stor_.useris non-empty (e.g., schema validators, dashboards). If unsure, I can provide a quick repo scan script to flag such assumptions.
If uv_get_process_title fails, ProcessMetrics::Update continues and leaves the title field empty instead of returning early. This prevents metrics collection from failing due to a missing process title, improving robustness in edge cases.
ff5c452 to
b6ab935
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
♻️ Duplicate comments (1)
src/nsolid.cc (1)
251-252: Resolved UB risk: assign from guarded locals.Assigning
stor_.title/stor_.userfromtitle/useravoids reading from potentially uninitialized buffers.
🧹 Nitpick comments (1)
src/nsolid.cc (1)
214-225: Graceful fallback for process title — LGTM; consider UV_ENOBUFS best-effort.Good move to avoid early return and to guard the assignment via a safe
std::string. Optionally, ifuv_get_process_title()populates a truncated buffer onUV_ENOBUFS, you could still keep a best‑effort title:- er = uv_get_process_title(title_buf, sizeof(title_buf)); - if (er == 0) { + er = uv_get_process_title(title_buf, sizeof(title_buf)); + if (er == 0 || er == UV_ENOBUFS) { title = title_buf; }Validate libuv’s behavior before adopting.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/nsolid.cc(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: test-linux (ubuntu-24.04-arm)
- GitHub Check: test-linux (ubuntu-24.04)
- GitHub Check: test-macOS
- GitHub Check: build-tarball
- GitHub Check: lint-js-and-md
- GitHub Check: coverage-windows
🔇 Additional comments (1)
src/nsolid.cc (1)
241-245: passwd lookup handled correctly — no downstream non-emptyuserassumptions found.Searched consumers/tests referencing the metric; only usages propagate or validate presence (test/common/nsolid-metrics-util.js, test/common/nsolid-grpc-agent/index.js) and none assert a non-empty string — no change required.
If nsolid is running as a user without a name (e.g. system user), uv_os_get_passwd may fail. This change ensures ProcessMetrics::Update still fills metrics and does not return early in that case, leaving the user field empty instead of failing the update. PR-URL: #364 Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
If uv_get_process_title fails, ProcessMetrics::Update continues and leaves the title field empty instead of returning early. This prevents metrics collection from failing due to a missing process title, improving robustness in edge cases. PR-URL: #364 Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
|
Landed in a296caf...ae1497d |
If nsolid is running as a user without a name (e.g. system user), uv_os_get_passwd may fail. This change ensures ProcessMetrics::Update still fills metrics and does not return early in that case, leaving the user field empty instead of failing the update. PR-URL: #364 Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
If uv_get_process_title fails, ProcessMetrics::Update continues and leaves the title field empty instead of returning early. This prevents metrics collection from failing due to a missing process title, improving robustness in edge cases. PR-URL: #364 Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
If nsolid is running as a user without a name (e.g. system user), uv_os_get_passwd may fail. This change ensures ProcessMetrics::Update still fills metrics and does not return early in that case, leaving the user field empty instead of failing the update. PR-URL: #364 Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
If uv_get_process_title fails, ProcessMetrics::Update continues and leaves the title field empty instead of returning early. This prevents metrics collection from failing due to a missing process title, improving robustness in edge cases. PR-URL: #364 Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
If nsolid is running as a user without a name (e.g. system user), uv_os_get_passwd may fail. This change ensures ProcessMetrics::Update still fills metrics and does not return early in that case, leaving the user field empty instead of failing the update.
Summary by CodeRabbit