amazon-q-developer-cli icon indicating copy to clipboard operation
amazon-q-developer-cli copied to clipboard

Improperly formed request. for any prompt

Open andy-root opened this issue 1 year ago • 9 comments

Checks

Operating system

macOS 15.3.2 (24D81)

Expected behaviour

Expect to run a prompt

Actual behaviour

got an error

Amazon Q is having trouble responding right now: 
   0: unhandled error (ValidationException)
   1: service error
   2: unhandled error (ValidationException)
   3: Error { code: "ValidationException", message: "Improperly formed request.", aws_request_id: "818720c5-7414-41a6-9e94-80b1b1576ba0" }

Location:
   crates/q_cli/src/cli/chat/mod.rs:468

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.
Amazon Q is having trouble responding right now: 
   0: unhandled error (ValidationException)
   1: service error
   2: unhandled error (ValidationException)
   3: Error { code: "ValidationException", message: "Improperly formed request.", aws_request_id: "c22c5aa0-f1f5-4fa6-aeff-7fa1725b8756" }

Location:
   crates/q_cli/src/cli/chat/mod.rs:468

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.
Amazon Q is having trouble responding right now: 
   0: unhandled error (ValidationException)
   1: service error
   2: unhandled error (ValidationException)
   3: Error { code: "ValidationException", message: "Improperly formed request.", aws_request_id: "05b6afdd-95a2-436d-9b7c-a8fc229c9033" }

Location:
   crates/q_cli/src/cli/chat/mod.rs:468

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.

Steps to reproduce

enter any prompt

Environment

[q-details]
version = "1.7.2"
hash = "b6bf5f1675dd7395009e8bc65c1145820671f211"
date = "2025-03-21T01:36:16.66764Z (11d ago)"
variant = "full"

[system-info]
os = "macOS 15.3.2 (24D81)"
chip = "Apple M3 Pro"
total-cores = 12
memory = "36.00 GB"

[environment]
cwd = "/Volumes/workplace/AXIOM/src/DevicesPlanningInspectWebsite"
cli-path = "/Volumes/workplace/AXIOM/src/DevicesPlanningInspectWebsite"
os = "Mac"
shell-path = "/bin/zsh"
shell-version = "5.9"
terminal = "VSCode"
install-method = "unknown"

[env-vars]
PATH = "/Users/USER/.local/share/mise/installs/node/18.20.2/bin:/Users/USER/.local/share/mise/installs/python/3.12.7/bin:/Users/USER/.local/share/mise/installs/python/3.11.10/bin:/Users/USER/.local/share/mise/installs/python/3.10.15/bin:/Users/USER/.local/share/mise/installs/python/3.9.20/bin:/Users/USER/.local/share/mise/installs/python/3.8.20/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Users/USER/.cargo/bin:/Users/USER/.local/bin:/Applications/Visual Studio Code.app/Contents/Resources/app/bin:/Users/USER/Library/Application Support/JetBrains/Toolbox/scripts:/Users/USER/.toolbox/bin"
QTERM_SESSION_ID = "082fe49061d048e88aafca1922e7ca44"
Q_SET_PARENT_CHECK = "1"
Q_TERM = "1.7.2"
SHELL = "/bin/zsh"
TERM = "xterm-256color"
ZDOTDIR = "/Users/USER"
__CFBundleIdentifier = "com.microsoft.VSCode"

andy-root avatar Mar 31 '25 22:03 andy-root

This error occurs when the context passed to the model is too large. We are going to

  1. Add a better error message
  2. Improve truncation logic

mschrage avatar Apr 01 '25 00:04 mschrage

I had the same issue, every prompt. I was able to get past it via /context clear and /context clear --global. The very next prompt worked.

sh4m1l65 avatar Apr 16 '25 02:04 sh4m1l65

The root cause has been resolved. Please open a new issue if you're still experiencing this bug.

mschrage avatar May 08 '25 21:05 mschrage

Hi team, i developed HelloWorld mcp server sample with q developer, here is the mcp server code

from mcp.server.fastmcp import FastMCP

mcp = FastMCP('hello')

@mcp.tool()
def say_hi():
    print('Hello')

if __name__ == '__main__':
    mcp.run(transport='stdio')

and i placed the mcp.json on ~/.aws/amazonq with below content

{
  "mcpServers": {
    "hello": {
      "command": "/q-developer-workshop/file-server/venv/bin/python",
      "args": ["/q-developer-workshop/file-server/HelloWorld.py"],
      "env": {
        "ENV_VAR1": "value1",
        "ENV_VAR2": "value2"
      }
    }
  }
}

From q developer cli, i can see my mcp tool info by /tools commond

hello (MCP):

  • hello___say_hi * not trusted

But when i run any prompt, it show below error messages

> hello

Amazon Q is having trouble responding right now: 
   0: unhandled error (ValidationException)
   1: service error
   2: unhandled error (ValidationException)
   3: Error { code: "ValidationException", message: "Improperly formed request.", aws_request_id: "dbf4d8f8-d565-4ed5-a8cf-b48e67d99bd2" }

aqiao avatar May 13 '25 07:05 aqiao

Appending more log with q chat --v

⠋ Thinking...2025-05-13T08:27:41.441552Z ERROR q_chat: 949: An error occurred processing the current state e=Client(CodewhispererGenerateAssistantResponse(ServiceError(ServiceError { source: Unhandled(Unhandled { source: ErrorMetadata { code: Some("ValidationException"), message: Some("Improperly formed request."), extras: Some({"aws_request_id": "0049a218-7f3b-426d-8a42-8e3ca10ce701"}) }, meta: ErrorMetadata { code: Some("ValidationException"), message: Some("Improperly formed request."), extras: Some({"aws_request_id": "0049a218-7f3b-426d-8a42-8e3ca10ce701"}) } }), raw: Response { status: StatusCode(400), headers: Headers { headers: {"date": HeaderValue { _private: H1("Tue, 13 May 2025 08:27:41 GMT") }, "content-type": HeaderValue { _private: H1("application/x-amz-json-1.0") }, "content-length": HeaderValue { _private: H1("100") }, "connection": HeaderValue { _private: H1("keep-alive") }, "x-amzn-requestid": HeaderValue { _private: H1("0049a218-7f3b-426d-8a42-8e3ca10ce701") }, "x-xss-protection": HeaderValue { _private: H1("1; mode=block") }, "strict-transport-security": HeaderValue { _private: H1("max-age=47304000; includeSubDomains") }, "x-frame-options": HeaderValue { _private: H1("DENY") }, "cache-control": HeaderValue { _private: H1("no-cache") }, "x-content-type-options": HeaderValue { _private: H1("nosniff") }} }, body: SdkBody { inner: Once(Some(b"{"__type":"com.amazon.aws.codewhisperer#ValidationException","message":"Improperly formed request."}")), retryable: true }, extensions: Extensions { extensions_02x: Extensions, extensions_1x: Extensions } } })))

aqiao avatar May 13 '25 08:05 aqiao

Why this keep coming even only saying HELLO

Improperly formed request.

Request ID: c18363d8-448b-4d74-9236-dc48aceb51a4

vanlalsiama1 avatar May 13 '25 11:05 vanlalsiama1

I have no idea, do you need any other information, or could you guide me how to do troubleshooting?

aqiao avatar May 13 '25 15:05 aqiao

@mschrage Could you please take a look ?

aqiao avatar May 13 '25 15:05 aqiao

I just hit this for the first time just now. Question - where does Q store this context? I'm assuming its on the local filesystem somewhere? What is the limit for how much context can be fed into the LLM? I was hitting an error with my MCP server with Q CLI and Cursor, but not Claude Desktop. Is there any reason this may not be happening for Claude Desktop?

novekm avatar Jun 10 '25 08:06 novekm