fix: bedrock chat tool arguments - #3564
Conversation
|
tejas ghatte seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
📝 WalkthroughWalkthroughA single-file change to the Bedrock provider's tool-call conversion function: when tool-call arguments fail JSON compacting, the Bedrock tool input now defaults to an empty JSON object ( ChangesBedrock tool-call conversion
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Confidence Score: 4/5Safe to merge — the change eliminates a code path that would have caused Bedrock API failures and introduces no new functional risk. The fix is correct and targeted: the previous behavior of forwarding a raw invalid JSON string to Bedrock was worse than discarding it. The only concern is that the silent discard produces no log output, which could make it hard to notice in production when tool arguments are unexpectedly lost. core/providers/bedrock/utils.go — worth considering whether a warn log should be added when arguments are silently dropped. Important Files Changed
Reviews (1): Last reviewed commit: "fix: bedrock chat tool arguments" | Re-trigger Greptile |
Merge activity
|
## Summary
When a tool call contains invalid JSON arguments, the Bedrock provider now falls back to an empty JSON object `{}` instead of forwarding the malformed payload. This prevents downstream errors caused by passing invalid JSON to the Bedrock API.
## Changes
- When `json.Compact` fails on tool call arguments, the input is now set to `{}` rather than preserving the raw (invalid) string. Forwarding invalid JSON to Bedrock would cause API errors, so discarding it in favor of a safe empty object is the correct behavior.
## Type of change
- [x] Bug fix
- [ ] Feature
- [ ] Refactor
- [ ] Documentation
- [ ] Chore/CI
## Affected areas
- [ ] Core (Go)
- [ ] Transports (HTTP)
- [x] Providers/Integrations
- [ ] Plugins
- [ ] UI (React)
- [ ] Docs
## How to test
Construct a tool call with malformed JSON arguments and send it through the Bedrock provider. Verify that the request succeeds and the tool input is treated as an empty object rather than causing a serialization or API error.
```sh
go test ./core/providers/bedrock/...
```
## Breaking changes
- [ ] Yes
- [x] No
## Related issues
## Security considerations
No security implications. Invalid input is sanitized to an empty object rather than being forwarded.
## Checklist
- [ ] I read `docs/contributing/README.md` and followed the guidelines
- [ ] I added/updated tests where appropriate
- [ ] I updated documentation where needed
- [ ] I verified builds succeed (Go and UI)
- [ ] I verified the CI pipeline passes locally if applicable

Summary
When a tool call contains invalid JSON arguments, the Bedrock provider now falls back to an empty JSON object
{}instead of forwarding the malformed payload. This prevents downstream errors caused by passing invalid JSON to the Bedrock API.Changes
json.Compactfails on tool call arguments, the input is now set to{}rather than preserving the raw (invalid) string. Forwarding invalid JSON to Bedrock would cause API errors, so discarding it in favor of a safe empty object is the correct behavior.Type of change
Affected areas
How to test
Construct a tool call with malformed JSON arguments and send it through the Bedrock provider. Verify that the request succeeds and the tool input is treated as an empty object rather than causing a serialization or API error.
go test ./core/providers/bedrock/...Breaking changes
Related issues
Security considerations
No security implications. Invalid input is sanitized to an empty object rather than being forwarded.
Checklist
docs/contributing/README.mdand followed the guidelines