Skip to content

AIP-121: Immutable field produces "mutable resource reference introduces a reference cycle" #1603

@loeffel-io

Description

@loeffel-io

Hey @noahdietz and @quirogas

i think i found an issue 🤔

This project still runs v2.0.0 but should be still present in v2.3.0

message UserEntitlement {
  option (google.api.resource) = {
    type: "billing.mindful.com/UserEntitlement"
    pattern: "projects/{project}/users/{user}/entitlements/{user_entitlement}"
    singular: "userEntitlement"
    plural: "userEntitlements"
  };
  // The resource name.
  // Format: projects/{project}/users/{user}/entitlements/{user_entitlement}
  string name = 1 [
    (google.api.field_behavior) = IDENTIFIER,
    (buf.validate.field).string = {pattern: "^projects\\/[a-z]([a-z0-9-]{0,61}[a-z0-9])?\\/users\\/[a-zA-Z0-9-]{1,128}\\/entitlements\\/[a-z]([a-z0-9-]{0,61}[a-z0-9])?$"},
    (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE
  ];
  // The previous entitlement.
  // Format: projects/{project}/users/{user}/entitlements/{user_entitlement}
  string previous_entitlement = 2 [
    (google.api.field_behavior) = IMMUTABLE, <-------------------------------
    (google.api.resource_reference) = {type: "billing.mindful.com/UserEntitlement"},
    (buf.validate.field).string = {pattern: "^projects\\/[a-z]([a-z0-9-]{0,61}[a-z0-9])?\\/users\\/[a-zA-Z0-9-]{1,128}\\/entitlements\\/[a-z]([a-z0-9-]{0,61}[a-z0-9])?$"},
    (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE
  ];
  problems:
    - message: |-
        mutable resource reference introduces a reference cycle:
        billing.mindful.com/UserEntitlement > billing.mindful.com/UserEntitlement
      location:
        start_position:
            line_number: 150
            column_number: 5
        end_position:
            line_number: 150
            column_number: 83
        path: mindful/earth/billing/user/v1/user_entitlement.proto
      rule_id: core::0121::no-mutable-cycles
      rule_doc_uri: https://linter.aip.dev/121/no-mutable-cycles

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions