Skip to content

go tool directive make the upload fail #26

@zaibon

Description

@zaibon

I was trying to upload a package that uses a tool directive in the go.mod and discovered that it makes the upload fail.

Here is the go.mod that fails:

module archipelo.com/api

go 1.24.3

tool github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen

require (
	github.com/getkin/kin-openapi v0.132.0
	github.com/kataras/iris/v12 v12.2.11
	github.com/oapi-codegen/runtime v1.1.1
)

While the same without the tool directive works:

module archipelo.com/api

go 1.24.3

require (
	github.com/getkin/kin-openapi v0.132.0
	github.com/kataras/iris/v12 v12.2.11
	github.com/oapi-codegen/runtime v1.1.1
)

Is that a current limitation?

Here is the command I use and the logs:


gcloud artifacts go upload --project=myproject --repository=api-specification      --location=us-central1 --module-path=github.com/zaibon/api --version=v0.0.3 --verbosity=debug
DEBUG: Running [gcloud.artifacts.go.upload] with arguments: [--location: "us-central1", --module-path: "github.com/zaibon/api", --project: "myproject", --repository: "api-specification", --verbosity: "debug", --version: "v0.0.3"]
DEBUG: Executing command: ['/opt/homebrew/share/google-cloud-sdk/bin/package-go-module', '--module_path=github.com/zaibon/api', '--version=v0.0.3', '--source=.', '--output=/var/folders/51/26y2rshs55qgkg24c4ptz91w0000gq/T/tmp8pm0ql2q/go.zip']
DEBUG: Starting new HTTPS connection (1): artifactregistry.googleapis.com:443
DEBUG: https://artifactregistry.googleapis.com:443 "POST /upload/v1/projects/myproject/locations/us-central1/repositories/api-specification/goModules:create?alt=json&uploadType=multipart HTTP/11" 200 252
Uploading package...⠹DEBUG: https://artifactregistry.googleapis.com:443 "GET /v1/projects/myproject/locations/us-central1/operations/a2bac58e-3919-4777-992a-a540ceedf53c?alt=json HTTP/11" 200 None
Uploading package...failed.                                                                                      
DEBUG: (gcloud.artifacts.go.upload) different go.mod file path prefix ("github.com/zaibon/api") and module path in go.mod file ("github.com/zaibon/api")
Traceback (most recent call last):
  File "/opt/homebrew/share/google-cloud-sdk/lib/googlecloudsdk/calliope/cli.py", line 985, in Execute
    resources = calliope_command.Run(cli=self, args=args)
  File "/opt/homebrew/share/google-cloud-sdk/lib/googlecloudsdk/calliope/backend.py", line 945, in Run
    resources = command_instance.Run(args)
  File "/opt/homebrew/share/google-cloud-sdk/lib/surface/artifacts/go/upload.py", line 117, in Run
    result = waiter.WaitFor(
        waiter.CloudOperationPollerNoResources(
            client.projects_locations_operations), op_ref,
        'Uploading package')
  File "/opt/homebrew/share/google-cloud-sdk/lib/googlecloudsdk/api_lib/util/waiter.py", line 261, in WaitFor
    operation = PollUntilDone(
        poller, operation_ref, max_retrials, max_wait_ms,
        exponential_sleep_multiplier, jitter_ms, wait_ceiling_ms,
        sleep_ms, _StatusUpdate)
  File "/opt/homebrew/share/google-cloud-sdk/lib/googlecloudsdk/api_lib/util/waiter.py", line 322, in PollUntilDone
    operation = retryer.RetryOnResult(
        func=poller.Poll,
        args=(operation_ref,),
        should_retry_if=_IsNotDone,
        sleep_ms=sleep_ms)
  File "/opt/homebrew/share/google-cloud-sdk/lib/googlecloudsdk/core/util/retry.py", line 249, in RetryOnResult
    if not should_retry(result, state):
           ~~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "/opt/homebrew/share/google-cloud-sdk/lib/googlecloudsdk/api_lib/util/waiter.py", line 320, in _IsNotDone
    return not poller.IsDone(operation)
               ~~~~~~~~~~~~~^^^^^^^^^^^
  File "/opt/homebrew/share/google-cloud-sdk/lib/googlecloudsdk/api_lib/util/waiter.py", line 182, in IsDone
    raise OperationError(operation.error.message)
googlecloudsdk.api_lib.util.waiter.OperationError: different go.mod file path prefix ("github.com/zaibon/api") and module path in go.mod file ("github.com/zaibon/api")
ERROR: (gcloud.artifacts.go.upload) different go.mod file path prefix ("github.com/zaibon/api") and module path in go.mod file ("github.com/zaibon/api")
error: Recipe `publish` failed on line 17 with exit code 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions