这是indexloc提供的服务,不要输入任何密码
Skip to content

pana fails with custom PUB_HOSTED_URL containing a path #1521

@jakob-grabner

Description

@jakob-grabner

When using a custom PUB_HOSTED_URL that includes a path (e.g., hosted on a custom Artifactory server), the pana command fails to analyze packages. The issue seems to occur because the pana package strips away the path component of the PUB_HOSTED_URL when resolving the API endpoint.

Steps to Reproduce

  1. Set a custom PUB_HOSTED_URL with a path, for example:

PUB_HOSTED_URL="https://artifactory-customdomain.org/artifactory/api/pub/registry-pub-dev"

  1. Run pana

The pana command fails with the following error:

FINE: Downloading: https://artifactory-customdomain.org/api/packages/analyzer
2025-11-11 14:56:47.106328 SHOUT: Problem analyzing
                                  Exception: "https://artifactory-customdomain.org/api/packages/analyzer" returned with status code 404.
                                  #0      getVersionListing.<anonymous closure> (package:pana/src/utils.dart:181:9)
                                  <asynchronous suspension>
                                  #1      RetryOptions.retry (package:retry/retry.dart:131:16)
                                  <asynchronous suspension>
                                  #2      getVersionListing (package:pana/src/utils.dart:172:10)
                                  <asynchronous suspension>
                                  #3      computeOutdatedVersions (package:pana/src/report/dependencies.dart:380:5)
                                  <asynchronous suspension>
                                  #4      trustworthyDependency.dependencies (package:pana/src/report/dependencies.dart:45:41)
                                  <asynchronous suspension>
                                  #5      trustworthyDependency (package:pana/src/report/dependencies.dart:307:29)
                                  <asynchronous suspension>
                                  #6      createReport (package:pana/src/report/create_report.dart:39:30)
                                  <asynchronous suspension>
                                  #7      PackageAnalyzer._inspect (package:pana/src/package_analyzer.dart:225:20)
                                  <asynchronous suspension>
                                  #8      PackageAnalyzer.inspectDir.<anonymous closure>.<anonymous closure> (package:pana/src/package_analyzer.dart:98:16)
                                  <asynchronous suspension>
                                  #9      withTempDir (package:pana/src/utils.dart:139:12)
                                  <asynchronous suspension>
                                  #10     main (file:///Users/jakob.grabner/.pub-cache/hosted/pub.dev/pana-0.23.1/bin/pana.dart:236:19)
                                  <asynchronous suspension>

The issue appears to originate in the getVersionListing function in utils.dart.
Specifically, the resolve method is used to construct the API endpoint URL, but it replaces the path of the pubHostedUrl with /api/packages/$package instead of appending it:

final url = (pubHostedUrl ?? Uri.parse('https://pub.dartlang.org')).resolve(
    '/api/packages/$package',
  );

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions