Aider-AI / aider

aider is AI pair programming in your terminal
https://aider.chat/
Apache License 2.0
22.71k stars 2.11k forks source link

Uncaught BadRequestError in exception_mapping_utils.py line 1068 #2247

Closed poclerson closed 2 weeks ago

poclerson commented 3 weeks ago

Aider version: 0.61.0 Python version: 3.12.4 Platform: macOS-15.0.1-arm64-arm-64bit Python implementation: CPython Virtual environment: Yes OS: Darwin 24.0.0 (64bit) Git version: git version 2.37.3

An uncaught exception occurred:

Traceback (most recent call last):
  File "handler.py", line 565, in completion
    response = client.post(
               ^^^^^^^^^^^^
  File "http_handler.py", line 386, in post
    raise e
  File "http_handler.py", line 372, in post
    response.raise_for_status()
  File "_models.py", line 763, in raise_for_status
    raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Client error '400 Bad Request' for url 'https://us-east5-aiplatform.googleapis.com/v1/projects/okam-internal/locations/us-east5/publishers/anthropic/models/claude-3-haiku@20240307:rawPredict'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "main.py", line 200, in completion
    return anthropic_chat_completions.completion(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "handler.py", line 580, in completion
    raise AnthropicError(
litellm.llms.anthropic.common_utils.AnthropicError: {
  "error": {
    "code": 400,
    "message": "Project `724920258599` is not allowed to use Publisher Model `projects/okam-internal/locations/us-east5/publishers/anthropic/models/claude-3-haiku@20240307`",
    "status": "FAILED_PRECONDITION"
  }
}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "main.py", line 2298, in completion
    model_response = vertex_partner_models_chat_completion.completion(
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "main.py", line 239, in completion
    raise VertexAIError(status_code=500, message=str(e))
litellm.llms.vertex_ai_and_google_ai_studio.vertex_ai_partner_models.main.VertexAIError: {
  "error": {
    "code": 400,
    "message": "Project `724920258599` is not allowed to use Publisher Model `projects/okam-internal/locations/us-east5/publishers/anthropic/models/claude-3-haiku@20240307`",
    "status": "FAILED_PRECONDITION"
  }
}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "aider", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "main.py", line 824, in main
    coder.run()
  File "base_coder.py", line 738, in run
    self.run_one(user_message, preproc)
  File "base_coder.py", line 781, in run_one
    list(self.send_message(message))
  File "base_coder.py", line 1278, in send_message
    saved_message = self.auto_commit(edited)
                    ^^^^^^^^^^^^^^^^^^^^^^^^
  File "base_coder.py", line 1979, in auto_commit
    res = self.repo.commit(fnames=edited, context=context, aider_edits=True)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "repo.py", line 110, in commit
    commit_message = self.get_commit_message(diffs, context)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "repo.py", line 195, in get_commit_message
    commit_message = simple_send_with_retries(
                     ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "sendchat.py", line 118, in simple_send_with_retries
    _hash, response = send_completion(**kwargs)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "sendchat.py", line 98, in send_completion
    res = litellm.completion(**kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "utils.py", line 1013, in wrapper
    raise e
  File "utils.py", line 903, in wrapper
    result = original_function(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "main.py", line 2999, in completion
    raise exception_type(
          ^^^^^^^^^^^^^^^
  File "exception_mapping_utils.py", line 2116, in exception_type
    raise e
  File "exception_mapping_utils.py", line 1068, in exception_type
    raise BadRequestError(
litellm.exceptions.BadRequestError: litellm.BadRequestError: VertexAIException BadRequestError - {
  "error": {
    "code": 400,
    "message": "Project `724920258599` is not allowed to use Publisher Model `projects/okam-internal/locations/us-east5/publishers/anthropic/models/claude-3-haiku@20240307`",
    "status": "FAILED_PRECONDITION"
  }
}
paul-gauthier commented 2 weeks ago

Thanks for trying aider and filing this issue.

The fix is available in the main branch. You can get it by installing the latest version from github:

aider --install-main-branch

# or...

python -m pip install --upgrade --upgrade-strategy only-if-needed git+https://github.com/Aider-AI/aider.git

If you have a chance to try it, let me know if it works better for you. I'm going to close this issue for now, but feel free to add a comment here and I will re-open. Or feel free to file a new issue any time.