googleapis/elixir-google-api

GoogleCloudMlV1_PredictRequest Mount Wrong URL

danieldocki opened this issue · 1 comments

Environment details

  • Programming language: Elixir
  • OS: macOS 12.1
  • Language runtime version: Elixir 1.13.1 (compiled with Erlang/OTP 24)
  • Package version: {:google_api_machine_learning, "~> 0.28.0"}

Steps to reproduce

Can run this livebook
https://gist.github.com/danieldocki/6b063661eee1062be322b9711f5b0814

the error is in the formation of the URL, as you can see in the error below

{:error,
 %Tesla.Env{
   __client__: %Tesla.Client{
     adapter: nil,
     fun: nil,
     post: [],
     pre: [
       {Tesla.Middleware.Headers, :call,
        [
          [
            {"authorization",
             "Bearer TOKEN"}
          ]
        ]}
     ]
   },
   __module__: GoogleApi.MachineLearning.V1.Connection,
   body: "{\n  \"error\": {\n    \"code\": 400,\n    \"message\": \"Field: name Error: The name should be a model or a version resource name, e.g 'projects/your-project-id/models/your-model-name' or 'projects/your-project-id/models/your-model-name/versions/your-version-name'.\",\n    \"status\": \"INVALID_ARGUMENT\",\n    \"details\": [\n      {\n        \"@type\": \"type.googleapis.com/google.rpc.BadRequest\",\n        \"fieldViolations\": [\n          {\n            \"field\": \"name\",\n            \"description\": \"The name should be a model or a version resource name, e.g 'projects/your-project-id/models/your-model-name' or 'projects/your-project-id/models/your-model-name/versions/your-version-name'.\"\n          }\n        ]\n      }\n    ]\n  }\n}\n",
   headers: [
     {"cache-control", "private"},
     {"date", "Thu, 13 Jan 2022 12:27:53 GMT"},
     {"accept-ranges", "none"},
     {"server", "ESF"},
     {"vary", "X-Origin"},
     {"content-length", "711"},
     {"content-type", "application/json; charset=UTF-8"},
     {"x-xss-protection", "0"},
     {"x-frame-options", "SAMEORIGIN"},
     {"x-content-type-options", "nosniff"},
     {"alt-svc",
      "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000,h3-Q050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\""}
   ],
   method: :post,
   opts: [],
   query: [],
   status: 400,
   url: "https://ml.googleapis.com/v1/projects/PROJECT_ID%2Fmodels%2FMODEL_NAME:predict"
 }}

was expected to assemble the URL
https://ml.googleapis.com/v1/projects/PROJECT_ID/models/MODEL_NAME:predict

This seems to be a breaking bug for the MachineLearning client. I can't find a way to specify a project and a model name. If I'm missing something, I'd love to know so I can use the library to access these services. Right now, I seem to always get PERMISSION_DENIED CONSUMER_INVALID when trying to just use the project id like the code seems to indicate.