jerryshao opened a new issue, #13191:
URL: https://github.com/apache/gravitino/issues/13191
### Version
main branch
### Describe what's wrong
`POST /api/lineage` returns `406 Not Acceptable` for every OpenLineage
client on current main, so lineage events sent through the OpenLineage HTTP
transport (for example from Spark, as in
`docs/lineage/gravitino-spark-lineage.md`) are rejected.
Root cause:
- `VersioningFilter` runs on `/api/*`. When the request has no versioned
media type, it replaces the `Accept` header with
`application/vnd.gravitino.v1+json`.
- `LineageOperations#postLineage` produces only `application/json`, which is
intended for OpenLineage compatibility. It cannot match the rewritten `Accept`,
so Jersey returns 406 before the method runs.
- This is a regression from #12384 (#12379). Before it,
`VersioningFilter.MutableHttpServletRequest` overrode `getHeader()` and
`getHeaderNames()` but not `getHeaders()`. Jersey's
`WebComponent#addRequestHeaders` reads headers only through `getHeaderNames()`
and `getHeaders(name)`, so the default-version rewrite never reached Jersey and
`application/json`-only resources kept working. #12384 added the `getHeaders()`
override, which made the rewrite effective.
Release branches `branch-1.0` through `branch-1.3` do not have the
`getHeaders()` override and are not affected.
Existing tests did not catch this because `TestLineageOperations` is a
`JerseyTest` that does not go through `VersioningFilter`.
### Error message and/or stacktrace
```
{"code":1000,"type":"RESTException","message":"HTTP 406 Not Acceptable"}
```
### How to reproduce
1. Build and start a server from main with default configuration (the HTTP
lineage source is enabled by default).
2. Send an OpenLineage event:
```
curl -X POST -H "Content-Type: application/json" -d '{...}'
http://localhost:8090/api/lineage
```
The result is the same with no `Accept` header, `Accept: */*`, or
`Accept: application/json`.
3. The server returns HTTP 406 instead of processing the event.
### Additional context
Suggested fix: when `VersioningFilter` applies the default version, keep the
client's original `Accept` values after the versioned media type (for example
`application/vnd.gravitino.v1+json, application/json`) instead of replacing
them. Gravitino resources still select the versioned type, while resources that
intentionally produce `application/json` (such as the OpenLineage endpoint)
match again.
Alternatively, `/api/lineage` could be excluded from the default-version
rewrite, but that needs a new exception for every externally compatible
endpoint.
A test that exercises `VersioningFilter` together with an
`application/json`-only resource would prevent this from regressing.
--
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]