Skip to content

Swift fails to resolve from package registry #29094

@cennis91

Description

@cennis91

Description

Resolving swift packages (swift package resolve) against the Gitea package registry fails:

error: 'scope.name': Failed fetching release checksum from registry: keyNotFound(CodingKeys(stringValue: "name", intValue: nil), Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "resources", intValue: nil), _JSONKey(stringValue: "Index 0", intValue: 0)], debugDescription: "No value associated with key CodingKeys(stringValue: "name", intValue: nil) ("name").", underlyingError: nil))

The issue comes from the Resource struct found here sending id in place of name.

type Resource struct {
	Name     string `json:"id"`
	Type     string `json:"type"`
	Checksum string `json:"checksum"`
}

I double checked to see if the specification changed or if this was just a typo. As far as I can tell, this was always meant to be name and not id (it seems to have been established here), so it's probably just a typo and not a breaking change.


For completeness:

.swiftpm/configuration/registries.json:

{
  "authentication" : {
    "gitea.example.com" : {
      "type" : "token"
    }
  },
  "registries" : {
    "[default]" : {
      "url" : "https://gitea.example.com/api/packages/user/swift"
    }
  },
  "version" : 1
}

Package.swift:

// swift-tools-version:5.8.1

import PackageDescription

let package = Package(
    name: "ExamplePackage",
    dependencies: [
        .package(id: "scope.name", from: "1.0.0")
    ]
)

Gitea Version

1.21.4

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

docker and command line

Database

None

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions