Skip to content

[BUG] Adding files to an existing shared-KB bot never ingests them: sync succeeds with an empty DataSources list #1129

Description

@NitroBoss

Describe the bug

Adding (or replacing) files on an existing bot that uses a shared knowledge base never ingests them. The sync completes with SyncStatus: SUCCEEDED, the UI looks healthy, but the new documents are absent from the knowledge base, so retrieval keeps answering only from the files present at bot creation. There is no error anywhere.

Root cause

On the update path (SyncSharedKnowledgeBasesRequired: falseMapQueuedBots flow), backend/embedding_statemachine/bedrock_knowledge_base/finalize_custom_bot_build.py builds the DataSources list for ingestion from exactly two sources:

  1. event["DataSources"] — only present when coming through the SharedKnowledgeBases creation flow.
  2. The BrChatKbStack{botId} CloudFormation outputs — a KnowledgeBaseId output only exists for dedicated knowledge bases.

For a shared-KB bot being updated, neither source exists, so the handler returns DataSources: []. The downstream ingestion Map state iterates over zero items and the state machine finishes successfully, dropping the file diff on the floor.

Confirmed from a live execution history: the FinalizeCustomBotBuild input contains the correct diff ("FilesDiff": {"Added": ["fileA.pdf", "fileB.pdf"], ...}) and no DataSources key; its output contains "DataSources": []; MapIngestionJobsForCustomBot schedules no tasks; UpdateSyncStatusSuccess then records SUCCEEDED.

Verified at v3.17.0 and on current v3 HEAD.

Steps to reproduce

  1. Create a bot with a shared knowledge base and some files; wait for the sync to complete (works).
  2. Edit the bot and add one more file; save. Sync completes successfully.
  3. aws bedrock-agent list-knowledge-base-documents on the bot's KB/data source: the new file is not there (not even as FAILED), and retrieval never uses it.

Expected behavior

Files added to an existing shared-KB bot are ingested, or the sync fails loudly.

Fix

The bot record already stores everything needed: update_knowledge_base_id() persists knowledge_base_id and data_source_ids on the bot at creation time. When the event carries file diffs but no DataSources, and the stack outputs expose no KnowledgeBaseId, fall back to the bot record. PR to follow.

Related: #1126 (same observability gap: the sync status reports success while nothing was ingested).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions