googleapis / google-api-go-client

Auto-generated Google APIs for Go.
https://pkg.go.dev/google.golang.org/api
BSD 3-Clause "New" or "Revised" License
4.04k stars 1.13k forks source link

Firebase Remote Config Project Not Found #2467

Closed caleberi closed 8 months ago

caleberi commented 8 months ago

Environment details

Steps to reproduce

  1. Create a new firebaseremoteconfig instance with the Service account file
  2. Request for the template from the instance
  3. Produces this error:
    googleapi: got HTTP response code 404 with body: <!DOCTYPE html>
        <html lang=en>
          <meta charset=utf-8>
          <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
          <title>Error 404 (Not Found)!!1</title>
          <style>
            *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlel
    ogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
          </style>
          <a href=//www.google.com/><span id=logo aria-label=Google></span></a>
          <p><b>404.</b> <ins>That’s an error.</ins>
          <p>The requested URL <code>/v1/{project-id}/remoteConfig</code> was not found on this server.  <ins>That’s all we know.</ins>

    Current Code In the Library (line 449)

    func (c *ProjectsGetRemoteConfigCall) doRequest(alt string) (*http.Response, error) {
    reqHeaders := make(http.Header)
    reqHeaders.Set("x-goog-api-client", "gl-go/1.13.7 gdcl/20200203")
    for k, v := range c.header_ {
        reqHeaders[k] = v
    }
    reqHeaders.Set("User-Agent", c.s.userAgent())
    if c.ifNoneMatch_ != "" {
        reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
    }
    var body io.Reader = nil
    c.urlParams_.Set("alt", alt)
    c.urlParams_.Set("prettyPrint", "false")
    urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+project}/remoteConfig")
    urls += "?" + c.urlParams_.Encode()
    req, err := http.NewRequest("GET", urls, body)
    if err != nil {
        return nil, err
    }
    req.Header = reqHeaders
    googleapi.Expand(req.URL, map[string]string{
        "project": c.projectid,
    })
    return gensupport.SendRequest(c.ctx_, c.s.client, req)
    }

Bug-Fix (line 449)

func (c *ProjectsGetRemoteConfigCall) doRequest(alt string) (*http.Response, error) {
    reqHeaders := make(http.Header)
    reqHeaders.Set("x-goog-api-client", "gl-go/1.13.7 gdcl/20200203")
    for k, v := range c.header_ {
        reqHeaders[k] = v
    }
    reqHeaders.Set("User-Agent", c.s.userAgent())
    if c.ifNoneMatch_ != "" {
        reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
    }
    var body io.Reader = nil
    c.urlParams_.Set("alt", alt)
    c.urlParams_.Set("prettyPrint", "false")
    urls := googleapi.ResolveRelative(c.s.BasePath, "v1/projects/{+project}/remoteConfig")
    urls += "?" + c.urlParams_.Encode()
    req, err := http.NewRequest("GET", urls, body)
    if err != nil {
        return nil, err
    }
    req.Header = reqHeaders
    googleapi.Expand(req.URL, map[string]string{
        "project": c.projectid,
    })
    return gensupport.SendRequest(c.ctx_, c.s.client, req)
}
codyoss commented 8 months ago

This is working as intended. It appears that the project ID field should be of that form already: https://github.com/googleapis/google-api-go-client/blob/67f16b6ada0cd92d94d98bb32f3bec61ca3472c6/firebaseremoteconfig/v1/firebaseremoteconfig-api.json#L123

codyoss commented 8 months ago

This client is no longer generated and has been stagnant for 2 years it looks like. We now surface these patterns in the Go doc for up-to-date clients.