goose icon indicating copy to clipboard operation
goose copied to clipboard

Unsupported MIME type: application/x-sh fails with AWS Bedrock provider

Open btiernay opened this issue 9 months ago • 1 comments

Describe the bug

When using Goose with AWS Bedrock I often get this error when it supplies a Shell script to the LLM:

Ran into this error: Server error: Failed to call Bedrock: ValidationException(ValidationException { message: Some("Unsupported MIME type: application/x-sh. Re
try your request with a supported file type: xlsx, txt, pdf, csv, md, doc, html, xls, docx"), meta: ErrorMetadata { code: Some("ValidationException"), message:
 Some("Unsupported MIME type: application/x-sh. Retry your request with a supported file type: xlsx, txt, pdf, csv, md, doc, html, xls, docx"), extras: Some({"
aws_request_id": "633ffad4-00b5-4282-9c07-dffa2678c50d"}) } }).

To Reproduce Steps to reproduce the behavior:

mkdir /tmp/test
cd /tmp/test
echo '#!/bin/bash
echo hi' > test.sh
goose run --text 'Summarize test.sh'
starting session | provider: bedrock model: us.anthropic.claude-3-7-sonnet-20250219-v1:0
    logging to /Users/share/goose/sessions/w94ubPyu.jsonl
I'll summarize the test.sh file for you. First, let me check if this file exists and then view its contents.

─── shell | developer ──────────────────────────
command: ls -l test.sh


-rw-r--r--  1  wheel  20 Mar  4 14:37 test.sh

Let me view the contents of the test.sh file:

─── text_editor | developer ──────────────────────────
path: /private/tmp/test/test.sh
command: view


### /private/tmp/test/test.sh
``bash
#!/bin/bash
echo hi

``

  2025-03-04T19:37:18.463091Z ERROR goose::agents::truncate: Error: Server error: Failed to call Bedrock: ValidationException(ValidationException { message: Some("Unsupported MIME type: application/x-sh. Retry your request with a supported file type: xlsx, txt, pdf, csv, md, doc, html, xls, docx"), meta: ErrorMetadata { code: Some("ValidationException"), message: Some("Unsupported MIME type: application/x-sh. Retry your request with a supported file type: xlsx, txt, pdf, csv, md, doc, html, xls, docx"), extras: Some({"aws_request_id": "e139f776-9e46-4fb9-a53d-d99d811f0246"}) } })
    at crates/goose/src/agents/truncate.rs:372

Ran into this error: Server error: Failed to call Bedrock: ValidationException(ValidationException { message: Some("Unsupported MIME type: application/x-sh. Re
try your request with a supported file type: xlsx, txt, pdf, csv, md, doc, html, xls, docx"), meta: ErrorMetadata { code: Some("ValidationException"), message:
 Some("Unsupported MIME type: application/x-sh. Retry your request with a supported file type: xlsx, txt, pdf, csv, md, doc, html, xls, docx"), extras: Some({"
aws_request_id": "e139f776-9e46-4fb9-a53d-d99d811f0246"}) } }).

Please retry if you think this is a transient or recoverable error.

In the logs:

  2025-03-04T19:37:18.300156Z DEBUG goose::agents::capabilities: input: "{\"name\":\"developer__text_editor\",\"arguments\":{\"command\":\"view\",\"path\":\"/private/tmp/test/test.sh\"}}", output: "{\"Ok\":[{\"type\":\"resource\",\"resource\":{\"uri\":\"file:///private/tmp/test/test.sh\",\"mime_type\":\"text\",\"text\":\"#!/bin/bash\\necho hi\\n\"},\"annotations\":{\"audience\":[\"assistant\"]}},{\"type\":\"text\",\"text\":\"### /private/tmp/test/test.sh\\n```bash\\n#!/bin/bash\\necho hi\\n\\n```\\n\",\"annotations\":{\"audience\":[\"user\"],\"priority\":0.0}}]}"
    at crates/goose/src/agents/capabilities.rs:540
    in goose::agents::capabilities::dispatch_tool_call
    in goose::agents::truncate::reply

  2025-03-04T19:37:18.462799Z ERROR goose::agents::truncate: Error: Server error: Failed to call Bedrock: ValidationException(ValidationException { message: Some("Unsupported MIME type: application/x-sh. Retry your request with a supported file type: xlsx, txt, pdf, csv, md, doc, html, xls, docx"), meta: ErrorMetadata { code: Some("ValidationException"), message: Some("Unsupported MIME type: application/x-sh. Retry your request with a supported file type: xlsx, txt, pdf, csv, md, doc, html, xls, docx"), extras: Some({"aws_request_id": "e139f776-9e46-4fb9-a53d-d99d811f0246"}) } })
    at crates/goose/src/agents/truncate.rs:372
    in goose::agents::truncate::reply

It looks as though this might be coming from here: https://github.com/block/goose/blob/7b767abfe60979e4d623da292b6ba4354b8ef8af/crates/goose/src/providers/formats/bedrock.rs#L170-L171

From the docs:

Valid Values: pdf | csv | doc | docx | xls | xlsx | html | txt | md

I think Goose maybe sending "text" instead of "txt": https://github.com/block/goose/blob/1c2332cc685225f4d0f5decf15590169467d6170/crates/mcp-core/src/resource.rs#L47

Additional context N/A

btiernay avatar Mar 04 '25 15:03 btiernay

This is a major issue, so kindly following up 🙇

btiernay avatar Mar 12 '25 18:03 btiernay

The issue is a blocker for my engineering teams as well

Dan-Wuensch avatar Mar 20 '25 17:03 Dan-Wuensch

Only been using Goose a few days and experienced this issue, but not specifically processing a .sh file. In my case I have an AWS CDK Project in TypeScript. The entry point file created by cdk init is /bin/somename.ts and Goose was chocking on this file with the "Unsupported MIME type: application/x-sh" error. Since I don't execute CDK TypeScript from the command line by running it directly, I simply dropped the shebang at the top of the file (#!/usr/bin/env node) and was able to get past the error.

bryan-valant avatar Mar 25 '25 00:03 bryan-valant

👋 Apologies on taking so long to triage this. I'm able to recreate this error and it looks like Bedrock is doing some additional validation on their end for Documents to match/infer doc types, which is a bit annoying. I'm putting together a fix where if the doc type is not supprted, we'll just pass the the text content through as Text content rather than Document. PR incoming!

zakiali avatar Mar 28 '25 02:03 zakiali

This PR should address this issue https://github.com/block/goose/pull/1899

zakiali avatar Mar 28 '25 05:03 zakiali

this is fixed in the latest canary on main. will be included in the next release

zakiali avatar Mar 28 '25 21:03 zakiali

Thanks so much!

Dan-Wuensch avatar Apr 10 '25 01:04 Dan-Wuensch