Skip to content

Fix Slack invalid_blocks error when usage metadata is empty#6

Open
rhegisan wants to merge 1 commit intokagent-dev:mainfrom
rhegisan:fix/slack-invalid-blocks
Open

Fix Slack invalid_blocks error when usage metadata is empty#6
rhegisan wants to merge 1 commit intokagent-dev:mainfrom
rhegisan:fix/slack-invalid-blocks

Conversation

@rhegisan
Copy link

@rhegisan rhegisan commented Feb 3, 2026

Summary

This PR fixes a Slack invalid_blocks error caused by rendering a Block Kit
context element with an empty text field.

Details

When usage_info is empty or unavailable, the Slack API rejects the message with:

Error Details: The request to the Slack API failed. (url: https://slack.com/api/chat.postMessage, status: 200)
The server responded with: {'ok': False, 'error': 'invalid_blocks', 'errors': ['must provide a string [json-pointer:/blocks/4/elements/0/text]']}

This change conditionally renders the usage metadata block only when valid
text is present, preventing message failures and improving bot stability.

Scope

  • ✅ Fixes Slack UI rendering errors
  • ❌ Does not change agent behavior, A2A responses, or Kubernetes logic

Testing

  • Verified /mykagent command no longer fails with invalid_blocks
  • Messages render correctly with and without usage metadata
Screenshot 2026-02-03 043257 Screenshot 2026-02-03 043409

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