Skip to content

fix: surface swallowed failures on data-library indexing and publish botId lookup (OBS follow-up) @W-24016300 - #352

Merged
nico-pappagianis merged 1 commit into
mainfrom
chore/logging-followup-obs-findings
Aug 28, 2026
Merged

fix: surface swallowed failures on data-library indexing and publish botId lookup (OBS follow-up) @W-24016300#352
nico-pappagianis merged 1 commit into
mainfrom
chore/logging-followup-obs-findings

Conversation

@nico-pappagianis

@nico-pappagianis nico-pappagianis commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #351 (logging standardization) that implements the three behavioral observability findings deferred out of that PR's review (OBS-1 / OBS-2 / OBS-5). #351 deliberately kept to a pure logging-format change; this PR makes the small behavior changes those findings actually require.

Draft / stacked on #351. Base is chore/standardize-logging, not main, because these changes build on the logCtx helper introduced in #351. Rebase onto main once #351 merges.

What changed

OBS-2 — getPublishedBotId no longer collapses every error into "not published"

singleRecordQuery throws SingleRecordQuery_NoRecords when zero rows match — that is the genuine "agent not yet published" case (→ debug, return undefined, POST a first version). Any other error (auth, network, multiple matches) means the lookup itself failed and we cannot tell whether the agent exists. Previously all of these collapsed to "not published", risking a duplicate first version POSTed over an existing agent. They now warn, emit agent_publish_botid_lookup_failed telemetry, and rethrow.

OBS-5 — KNOWLEDGE indexing trigger no longer swallows real failures

The fire-and-forget indexing fetch had an empty catch {}. An intentional 10s AbortError stays debug (the server processes indexing asynchronously on receipt, so a timeout is expected and harmless). A genuine failure — the request never reached the server — now warns, so a data library that silently never indexes is diagnosable.

OBS-1 — sole-signal swallow paths promoted above the default WARN capture

Logger.DEFAULT_LEVEL is WARN, so debug lines don't persist in a default production capture. OBS-1 asked that any path which is the only signal of a problem and swallows-and-continues log above that threshold. After OBS-2 and OBS-5, those were the only two such paths, and both now warn on genuine failure. The log-and-rethrow catches (agentDataLibrary, apiCatalog) correctly stay at debug — the throw plus its _failed telemetry is the durable signal, so promoting them would be log-and-throw double-reporting.

Tests

  • should return undefined when agent does not exist now simulates not-found with the realistic SingleRecordQuery_NoRecords SfError instead of a generic Error.
  • New: should rethrow when the lookup itself fails (not a genuine not-found).
  • Publish-error tests that relied on the old swallow behavior to reach the POST now stub the not-published lookup explicitly.

yarn tsc -b clean; yarn mocha → 420 passing, 1 pending.

Open question for review

OBS-2 changes a real lookup failure from swallow-and-continue to rethrow. That is the safer default (don't risk a duplicate publish when org state is unknown), but it does turn a previously-silent transient query blip into a hard publish failure. Flagging in case we'd rather warn + telemetry and still proceed. Draft pending that call.

@W-24016300

@nico-pappagianis
nico-pappagianis force-pushed the chore/logging-followup-obs-findings branch 3 times, most recently from 56ab7c7 to 7520eb0 Compare August 27, 2026 16:31
Base automatically changed from chore/standardize-logging to main August 27, 2026 19:29
@nico-pappagianis
nico-pappagianis force-pushed the chore/logging-followup-obs-findings branch from 70c5597 to b9e43ff Compare August 27, 2026 22:07
@nico-pappagianis
nico-pappagianis marked this pull request as ready for review August 27, 2026 22:13
@nico-pappagianis nico-pappagianis changed the title fix: surface swallowed failures on data-library indexing and publish botId lookup (OBS follow-up) fix: surface swallowed failures on data-library indexing and publish botId lookup (OBS follow-up) @W-24016300 Aug 27, 2026

@setu4993 setu4993 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fixes. Let's make sure CI is all green before we merge.

Follow-up to the msg-ctx logging standardization (#351), addressing two rounds
of observability/security review findings.

Data-library KNOWLEDGE indexing (agentDataLibrary):
- Check response.ok on the indexing fetch; native fetch resolves on 4xx/5xx, so
  HTTP errors (expired auth, 5xx, 429) were swallowed as success. HTTP and
  network failures now converge on one warn + agent_adl_indexing_trigger_failed
  telemetry event, statusCode distinguishing them. create() still resolves
  (indexing stays best-effort); the intentional 10s abort emits nothing.

publish botId lookup (scriptAgentPublisher.getPublishedBotId):
- Only SingleRecordQuery_NoRecords is treated as 'not yet published'; any other
  lookup error is surfaced (telemetry + rethrow) rather than swallowed, so we
  never POST a duplicate first version over an existing agent.
- Log at debug (not warn) on the rethrow path per ai-docs/logging.md; the
  rethrown error is the durable signal. Add statusCode to the log and telemetry.

SOQL hardening (CWE-89):
- Escape single quotes in interpolated identifiers (developerName, botVersionId,
  defaultAgentUser) using the repo's agentEvalRunner idiom.

Also standardizes the new-format retrieve log lines to msg-ctx and hardens the
CtxLogger emit path (single merging object so @salesforce/core's Logger does not
collapse fields under numeric keys). Adds tests for all of the above.
@nico-pappagianis
nico-pappagianis force-pushed the chore/logging-followup-obs-findings branch from 2c444c5 to 98bdef3 Compare August 28, 2026 16:49
@nico-pappagianis
nico-pappagianis merged commit 62fd019 into main Aug 28, 2026
26 of 27 checks passed
@nico-pappagianis
nico-pappagianis deleted the chore/logging-followup-obs-findings branch August 28, 2026 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants