Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken sql/sqladmin package #448

Closed
kacper-zylka opened this issue Feb 5, 2020 · 9 comments
Closed

Broken sql/sqladmin package #448

kacper-zylka opened this issue Feb 5, 2020 · 9 comments
Assignees
Labels
priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. 🚨 This issue needs some love. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@kacper-zylka
Copy link

Hello,

I've been getting this error since yesterday in our build tool, here it is reproduced:

> go get google.golang.org/api/...
can't load package: package google.golang.org/api/sqladmin/v1beta4: code in directory /Users/kacper/go/src/google.golang.org/api/sqladmin/v1beta4 expects import "google.golang.org/api/sql/v1beta4"

I believe this change:

- package sqladmin // import "google.golang.org/api/sqladmin/v1beta4"
+ package sql // import "google.golang.org/api/sql/v1beta4"

in sqladmin/v1beta4/sqladmin-gen.go in release 0.16.0 is responsible. It looks like the package sqladmin was merged into package sql but it cannot compile because they are still in different directories?

Please let me know if this is indeed the issue or if the problem is somewhere on our side.

@tbpg tbpg added priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Feb 5, 2020
@tbpg
Copy link
Contributor

tbpg commented Feb 5, 2020

Seems to be a problem on our side -- looking into it. Thank you for reporting this!

@broady
Copy link
Member

broady commented Feb 5, 2020

Very strange. The changes to the JSON discovery doc should not have caused that.

https://code-review.googlesource.com/c/google-api-go-client/+/51393/2/sqladmin/v1beta4/sqladmin-api.json#25

Will investigate.

@broady
Copy link
Member

broady commented Feb 5, 2020

The discovery doc changed substantially back in November:
https://code-review.googlesource.com/c/google-api-go-client/+/48474/2/sqladmin/v1beta4/sqladmin-api.json#b32

Strangely, it looks like sqladmin hadn't been re-generated since my manual re-generation (8c19f07) even though the discovery doc had changed several times.

The root cause is certainly that the discovery doc says "sql" when the API name is "sqladmin".

Root discovery service says:

    {
      "kind": "discovery#directoryItem",
      "id": "sql:v1beta4",
      "name": "sql",
      "version": "v1beta4",
      "title": "Cloud SQL Admin API",
      "description": "API for Cloud SQL database instance management",
      "discoveryRestUrl": "https://sqladmin.googleapis.com/$discovery/rest?version=v1beta4",
      "icons": {
        "x16": "https://www.gstatic.com/images/branding/product/1x/googleg_16dp.png",
        "x32": "https://www.gstatic.com/images/branding/product/1x/googleg_32dp.png"
      },
      "documentationLink": "https://developers.google.com/cloud-sql/",
      "preferred": true
    },
    {
      "kind": "discovery#directoryItem",
      "id": "sqladmin:v1beta4",
      "name": "sqladmin",
      "version": "v1beta4",
      "title": "Cloud SQL Admin API",
      "description": "Creates and manages Cloud SQL instances, which provide fully managed MySQL or PostgreSQL databases.",
      "discoveryRestUrl": "https://www.googleapis.com/discovery/v1/apis/sqladmin/v1beta4/rest",
      "discoveryLink": "./apis/sqladmin/v1beta4/rest",
      "icons": {
        "x16": "https://www.gstatic.com/images/branding/product/1x/googleg_16dp.png",
        "x32": "https://www.gstatic.com/images/branding/product/1x/googleg_32dp.png"
      },
      "documentationLink": "https://cloud.google.com/sql/docs/reference/latest",
      "preferred": true
    },

But the discovery doc at https://www.googleapis.com/discovery/v1/apis/sqladmin/v1beta4/rest says:

{
  "basePath": "",
  "ownerDomain": "google.com",
  "name": "sql",
  "batchPath": "batch",
  "revision": "20200124",
  "documentationLink": "https://developers.google.com/cloud-sql/",
  "id": "sql:v1beta4",
  "title": "Cloud SQL Admin API",
...

notice how name and id say "sql" and not "sqladmin"

@broady
Copy link
Member

broady commented Feb 5, 2020

I regenerated everything again and now it's back to the way it should be.

https://code-review.googlesource.com/c/google-api-go-client/+/51550

I found the issue: for the previous bad generation, I used make local, which is supposed to just not fetch new discovery docs, and produce the same output as make all (which fetches the latest discovery docs). But evidently that's not true. I will file a separate bug for that.

But this is also a bug in sqladmin's discovery doc.

@broady
Copy link
Member

broady commented Feb 5, 2020

This is the diff between running make all vs make local:

-// Package sqladmin provides access to the Cloud SQL Admin API.
+// Package sql provides access to the Cloud SQL Admin API.
-//   import "google.golang.org/api/sqladmin/v1beta4"
+//   import "google.golang.org/api/sql/v1beta4"
-//   sqladminService, err := sqladmin.NewService(ctx)
+//   sqlService, err := sql.NewService(ctx)
-//   sqladminService, err := sqladmin.NewService(ctx, option.WithScopes(sqladmin.SqlserviceAdminScope))
+//   sqlService, err := sql.NewService(ctx, option.WithScopes(sql.SqlserviceAdminScope))
-//   sqladminService, err := sqladmin.NewService(ctx, option.WithAPIKey("AIza..."))
+//   sqlService, err := sql.NewService(ctx, option.WithAPIKey("AIza..."))
-//   sqladminService, err := sqladmin.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
+//   sqlService, err := sql.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
-package sqladmin // import "google.golang.org/api/sqladmin/v1beta4"
+package sql // import "google.golang.org/api/sql/v1beta4"
-       StorageAutoResize *bool `json:"storageAutoResize,omitempty"`
+       StorageAutoResize bool `json:"storageAutoResize,omitempty"`

@tbpg
Copy link
Contributor

tbpg commented Feb 6, 2020

Next step is a v0.17.0 release, but leaving this closed.

You can depend on v0.16.1-0.20200206160949-b1dd6985e76a until we get that out.

@broady
Copy link
Member

broady commented Feb 6, 2020

v0.17.0 is tagged.

@kacper-zylka
Copy link
Author

Thank you all for looking into this so quickly!

@broady
Copy link
Member

broady commented Feb 7, 2020

Thank you for flagging it.

@yoshi-automation yoshi-automation added the 🚨 This issue needs some love. label Apr 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. 🚨 This issue needs some love. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

5 participants