Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Superseded operations paths do not align with defined paths #284

Closed
Xtansia opened this issue May 7, 2024 · 1 comment
Closed
Labels
bug Something isn't working

Comments

@Xtansia
Copy link
Collaborator

Xtansia commented May 7, 2024

What is the bug?

The paths defined in the _superseded_operations.yaml do not match with the paths defined in the rest of the spec.

For example:
In _superseded_operations.yaml we have:

/_opendistro/_security/api/internalusers/{name}:
  superseded_by: /_plugins/_security/api/internalusers/{name}
  operations:
    - GET
    - PUT
    - DELETE
    - PATCH

However in namespaces/security.yaml we have:

paths:
  /_plugins/_security/api/internalusers/{username}:
    get:
      operationId: security.get_user.0
      x-operation-group: security.get_user
      x-version-added: '1.0'
      description: Retrieve one internal user.
      externalDocs:
        url: https://opensearch.org/docs/latest/security/access-control/api/#get-user
      parameters:
        - $ref: '#/components/parameters/security.get_user::path.username'
      responses:
        '200':
          $ref: '#/components/responses/security.get_user@200'

The path parameter names do not match, which means on merging we get:

paths:
  /_opendistro/_security/api/internalusers/{name}:
    get:
      operationId: security.get_user.0_superseded
      x-operation-group: security.get_user
      x-version-added: '1.0'
      description: Retrieve one internal user.
      externalDocs:
        url: https://opensearch.org/docs/latest/security/access-control/api/#get-user
      parameters:
        - $ref: '#/components/parameters/security.get_user::path.username'
        - $ref: '#/components/parameters/_global::query.pretty'
        - $ref: '#/components/parameters/_global::query.human'
        - $ref: '#/components/parameters/_global::query.error_trace'
        - $ref: '#/components/parameters/_global::query.source'
        - $ref: '#/components/parameters/_global::query.filter_path'
      responses:
        '200':
          $ref: '#/components/responses/security.get_user@200'
      deprecated: true
      x-ignorable: true

This means the final spec is incorrect as the path specifies {name} but we only provide a path param named username

@Xtansia Xtansia added bug Something isn't working untriaged labels May 7, 2024
@dblock dblock removed the untriaged label May 7, 2024
@dblock
Copy link
Member

dblock commented Nov 7, 2024

This was fixed in #646 where the superseded_by value was incorrect (example) and the validator flagged the parameter.

/_opendistro/_rollup/jobs/{rollupID}:
  superseded_by: /_plugins/_rollup/jobs/{id}
  operations:
    - GET
    - HEAD
    - PUT
    - DELETE

Now becomes

  /_opendistro/_rollup/jobs/{id}:
    get:
      operationId: rollups.get.0_superseded
      x-operation-group: rollups.get
      x-version-added: '1.0'
      description: Get an index rollup.
      externalDocs:
        url: https://opensearch.org/docs/latest/im-plugin/index-rollups/rollup-api/#get-an-index-rollup-job
      parameters:
        - $ref: '#/components/parameters/rollups.get___path.id'
        - $ref: '#/components/parameters/_global___query.pretty'
        - $ref: '#/components/parameters/_global___query.human'
        - $ref: '#/components/parameters/_global___query.error_trace'
        - $ref: '#/components/parameters/_global___query.source'
        - $ref: '#/components/parameters/_global___query.filter_path'
      responses:
        '200':
          $ref: '#/components/responses/rollups.get___200'
      deprecated: true
      x-ignorable: true

The mapping happens in https://github.com/opensearch-project/opensearch-api-specification/blob/main/tools/src/merger/SupersededOpsGenerator.ts#L53.

Screenshot 2024-11-07 at 12 24 33 PM

@dblock dblock closed this as completed Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants