sundapeng opened a new pull request, #10571:
URL: https://github.com/apache/paimon/pull/10571
### Purpose
The label management API added in #9838 and #9848 addresses a binding by URL
path: `/v1/{prefix}/labels/{entityType}/{entityName}/{key}`. Entity names are
canonical names such as ``db.t.`a.b` ``, and keys are free text. Real
deployments cannot carry such strings in a path. We sent 37 sample strings
(backtick, `%`, `%41`, space, `+`, `#`, `?`, `&`, `=`, `/`, `\`, quotes,
brackets, `;`, `..`, CJK, emoji, tab, newline and others) to a DLF catalog on
its three REST routes: direct with the default DLF signer, and through the
Alibaba Cloud POP gateway with the `openapi` and with the `openapi-v4` signer.
| Carried in | Direct | POP, `openapi` | POP, `openapi-v4` |
|---|---|---|---|
| URL path | 31 exact, 5 wrong | 13 exact, 24 wrong | 15 exact, 22 wrong |
| Query parameter | 37/37 exact | 37/37 exact | 37/37 exact |
| JSON body | 37/37 exact | 37/37 exact | 37/37 exact |
In the path:
- The POP gateway rejects a backtick, backslash, double quote, angle
brackets, braces, pipe, caret, square brackets, tab and newline with "Illegal
Path Character" before the request reaches the server. Backticks are how
canonical names quote a component, so a column such as ``db.t.`a.b` `` cannot
be labelled through the gateway at all.
- With the `openapi` signer, `%`, space, `#`, `?` and non-ASCII text also
fail with HTTP 400; with `openapi-v4`, space, `+`, `*` and `~` do.
- Even direct to a Tomcat-based server, an encoded `/` or `\` is refused,
and the decode-once rule is easy to break: `+` arrived as a space and `%41` as
`A`.
This pull request keeps the four operations and their semantics and moves
only the identity out of the path:
| Operation | Before | After |
|---|---|---|
| List | `GET /v1/{prefix}/labels/{entityType}/{entityName}` | `GET
/v1/{prefix}/labels?entityType=&entityName=[&maxResults=][&pageToken=]` |
| Get | `GET .../labels/{entityType}/{entityName}/{key}` | `POST
/v1/{prefix}/labels/get` with `{entityType, entityName, key}` |
| Upsert | `POST .../labels/{entityType}/{entityName}` | `POST
/v1/{prefix}/labels/upsert` with `{entityType, entityName, key, value}` |
| Delete | `DELETE .../labels/{entityType}/{entityName}/{key}` | `POST
/v1/{prefix}/labels/delete` with `{entityType, entityName, key}` |
This follows `listPermissions` plus `permissions/grant` and
`permissions/revoke` in the same management API. Reading one binding becomes a
POST, like `partitions/list-by-names`, because GET and DELETE carry no body; it
stays read-only and safe to retry, and a missing key is still a LABEL 404 from
the server. Gateways that map an action from method and path, as the POP
gateway does, still see four distinct operations.
The label and semantic view routes are also registered in
`DLFOpenApiActions`, so the `openapi-v4` signer sends and signs `x-acs-action`
for them.
The label API is `@Experimental` and has not been released, so the wire
contract changes without a compatibility path. `RESTApi` method signatures are
unchanged.
Changes:
- `ResourcePaths`: `labels()`, `getLabel()`, `upsertLabel()`,
`deleteLabel()` replace the path builders that took a name and key.
- `RESTApi`: label calls use the new routes; new `GetLabelRequest` and
`DeleteLabelRequest`; `UpsertLabelRequest` carries the entity and key.
- `DLFOpenApiActions`: ListLabels, GetLabel, UpsertLabel, DeleteLabel,
ListSemanticViews, GetSemanticView, UpsertSemanticView, DeleteSemanticView.
- Docs: `management-api.md`, `rest-api.mdx`,
`rest-management-open-api.yaml`, and `validate-rest-openapi.js` now asserts the
new routes.
### Tests
- `RESTApiLabelTest`: routes, query parameters and bodies for names and keys
containing `/`, `%`, `+`, space, `#`, `?`, backticks, CJK and `..`, compared
byte for byte on the mock server.
- `RESTCatalogLabelManagementTest`, `RequestJacksonCompatibilityTest`,
`DLFOpenApiActionsTest` updated.
- `node docs/scripts/validate-rest-openapi.js` passes, and fails on the
previous YAML.
- End to end against a DLF catalog server built from the matching server
change: databases, tables and columns named with dots, doubled backticks, `/`,
`%41+`, `#?`, CJK and `..`, under keys of the same kind: 24 of 24 upsert, get,
list and delete round trips exact. The current client fails every case with `/`
against the same server, even direct.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]