GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Resource patterns with wildcard '*' results in failing test for parse_path · Issue #701 · googleapis/gapic-generator-python

This repository was archived by the owner on Aug 25, 2026. It is now read-only.
This repository was archived by the owner on Aug 25, 2026. It is now read-only.

Resource patterns with wildcard '*' results in failing test for parse_path #701

Copy link
Copy link
Closed
Closed
Resource patterns with wildcard '*' results in failing test for parse_path#701
Copy link
Labels
🚨This issue needs some love.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Description

@busunkim96
busunkim96
opened on Nov 18, 2020
Issue body actions

Asset has a resource path annotated with pattern *

https://github.com/googleapis/googleapis/blob/f1e0ce4dbc5f59448f441093014d712af442984f/google/cloud/asset/v1/assets.proto#L96-L100

message Asset {
  option (google.api.resource) = {
    type: "cloudasset.googleapis.com/Asset"
    pattern: "*"
  };

This results in a unhelpful set of resource name helpers:

    @staticmethod
    def asset_path() -> str:
        """Return a fully-qualified asset string."""
        return "*".format()

    @staticmethod
    def parse_asset_path(path: str) -> Dict[str, str]:
        """Parse a asset path into its component segments."""
        m = re.match(r"^*$", path)
        return m.groupdict() if m else {}

The generated tests break because of the *.

def test_asset_path():
    expected = "*".format()
    actual = AssetServiceClient.asset_path()
    assert expected == actual


def test_parse_asset_path():
    expected = {}
    path = AssetServiceClient.asset_path(**expected)

    # Check that the path construction is reversible.
    actual = AssetServiceClient.parse_asset_path(path)
    assert expected == actual
                if not item or item[0][0] is AT:
>                   raise source.error("nothing to repeat",
                                       source.tell() - here + len(this))
E                   re.error: nothing to repeat at position 1

../../.pyenv/versions/3.8.1/lib/python3.8/sre_parse.py:668: error

The * pattern is uncommon and this method isn't actually helpful for parsing paths. I'm planning on deleting it from the generated output for now.

Activity

  1. yoshi-automation
    added
    triage meI really want to be triaged.
    🚨This issue needs some love.
    on Nov 19, 2020
  2. vam-google
    added
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    priority: p2Moderately-important priority. Fix may not be included in next release.
    and removed
    triage meI really want to be triaged.
    on Dec 1, 2020
  3. yoshi-automation
    removed
    🚨This issue needs some love.
    on Dec 1, 2020
  4. busunkim96
    changed the title [-]Resource pattern '*' results in failing test for parse_path[/-] [+]Resource patterns with wildcard '*' results in failing test for parse_path[/+] on Dec 29, 2020
  5. busunkim96 commented on Dec 29, 2020

    @busunkim96
    busunkim96
    on Dec 29, 2020
    ContributorAuthor
    More actions

    Similar issue with monitoring which has a path with **.

    https://github.com/googleapis/googleapis/blob/69697504d9eba1d064820c3085b4750767be6d08/google/monitoring/v3/metric_service.proto#L39-L46

    option (google.api.resource_definition) = {
      type: "monitoring.googleapis.com/MetricDescriptor"
      pattern: "projects/{project}/metricDescriptors/{metric_descriptor=**}"
      pattern: "organizations/{organization}/metricDescriptors/{metric_descriptor=**}"
      pattern: "folders/{folder}/metricDescriptors/{metric_descriptor=**}"
      pattern: "*"
      history: ORIGINALLY_SINGLE_PATTERN
    };
        def metric_descriptor_path(project: str,) -> str:
            """Return a fully-qualified metric_descriptor string."""
            return "projects/{project}/metricDescriptors/{metric_descriptor=**}".format(
                project=project,
            )
    
        @staticmethod
        def parse_metric_descriptor_path(path: str) -> Dict[str, str]:
            """Parse a metric_descriptor path into its component segments."""
            m = re.match(
                r"^projects/(?P<project>.+?)/metricDescriptors/{metric_descriptor=**}$",
                path,
            )
            return m.groupdict() if m else {}
    def test_metric_descriptor_path():
        project = "squid"
    
        expected = "projects/{project}/metricDescriptors/{metric_descriptor=**}".format(
            project=project,
        )
        actual = MetricServiceClient.metric_descriptor_path(project)
        assert expected == actual
    
    
    def test_parse_metric_descriptor_path():
        expected = {
            "project": "clam",
        }
        path = MetricServiceClient.metric_descriptor_path(**expected)
    
        # Check that the path construction is reversible.
        actual = MetricServiceClient.parse_metric_descriptor_path(path)
        assert expected == actual
  6. yoshi-automation
    added
    🚨This issue needs some love.
    and removed
    🚨This issue needs some love.
    on Mar 30, 2021
  7. yoshi-automation
    added
    🚨This issue needs some love.
    on May 18, 2021
  8. vam-google commented on Jan 19, 2022

    @vam-google
    vam-google
    on Jan 19, 2022
    Contributor
    More actions

    @busunkim96 Is this issue still relevant?

  9. busunkim96 commented on Jan 20, 2022

    @busunkim96
    busunkim96
    on Jan 20, 2022
    ContributorAuthor
    More actions

    This was fixed by #1089.

  10. busunkim96
    closed this as completedon Jan 20, 2022
  11. parthea
    reopened this on Oct 20, 2023
  12. parthea
    closed this as completedon Oct 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    🚨This issue needs some love.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.