#23691: fix(pi-runner): resolve param shadowing in maybeMarkAuthProfileFailure
agents
size: XS
Cluster:
Error Handling in Agent Tools
## Problem
In `src/agents/pi-embedded-runner/run.ts`, the inner function `maybeMarkAuthProfileFailure` declares a parameter named `params`:
```ts
const maybeMarkAuthProfileFailure = async (params: {
profileId?: string;
reason?: ...;
}) => {
const { profileId, reason } = params;
// ...
await markAuthProfileFailure({
cfg: params.config, // ← undefined: inner params has no .config
agentDir: params.agentDir, // ← undefined: inner params has no .agentDir
});
};
```
The inner `params` shadows the outer function's `params` (which carries `config` and `agentDir`). As a result, `params.config` and `params.agentDir` silently resolve to `undefined`, so `markAuthProfileFailure` is called with missing context on every auth failure.
## Fix
Use destructuring in the function signature to eliminate the inner `params` binding. The body's `params.config` and `params.agentDir` references then correctly resolve to the enclosing scope.
## Testing
Single file changed, 4 lines diff. Existing auth-profile failure integration tests cover the call site.
## Notes
- Single file changed, 4 lines diff
- No API or type signature changes
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Fixes parameter shadowing bug in `maybeMarkAuthProfileFailure` that caused `cfg` and `agentDir` to be passed as `undefined` to `markAuthProfileFailure`. Changed from declaring a `params` parameter (which shadowed the outer scope) to using destructuring `{ profileId, reason }` in the function signature. This allows the function body to correctly access `params.config` and `params.agentDir` from the enclosing `runEmbeddedPiAgent` scope.
- Fixed silent failure: auth profile failures were being logged without proper context
- Clean refactor: eliminates shadowing by using destructuring instead of a parameter binding
- No breaking changes: call sites already pass objects with `profileId` and `reason` fields
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge - it fixes a clear bug with minimal, well-scoped changes
- The fix is correct, minimal (4 lines changed), and addresses a real bug where parameter shadowing caused `undefined` values to be passed. The change uses standard destructuring to eliminate the shadowing issue. No new logic introduced, no breaking changes to the function signature, and existing call sites are already compatible.
- No files require special attention
<sub>Last reviewed commit: 2c9deba</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#23680: fix(types): add missing config and agentDir params to maybeMarkAuth...
by NewdlDewdl · 2026-02-22
84.6%
#14368: fix: skip auth profile cooldown on format errors to prevent provide...
by koatora20 · 2026-02-12
77.4%
#21646: fix(cron): pass agentDir to runEmbeddedPiAgent for correct auth res...
by zhangjunmengyang · 2026-02-20
76.6%
#20851: fix: harden resolveUserPath and compact against undefined workspaceDir
by davidrudduck · 2026-02-19
75.9%
#22845: Pass agentDir through cron and followup embedded runs
by seilk · 2026-02-21
75.3%
#19385: fix: pass authProfileId from cron session to runEmbeddedPiAgent
by gigi-trifle · 2026-02-17
75.1%
#2541: fix(agents): add error handling to orphaned message cleanup
by Episkey-G · 2026-01-27
74.4%
#22707: fix: pass agentDir to runEmbeddedPiAgent in cron isolated sessions
by mrlerner · 2026-02-21
74.4%
#21271: fix(commands): pass channel/capabilities/shell/os to runtime in com...
by evansantos · 2026-02-19
74.1%
#23210: fix: avoid cooldown on timeout/unknown failovers
by nydamon · 2026-02-22
73.6%