mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-30 18:17:55 +00:00
Add a new log message, reporting collisions between OpenAPI paths (#20873)
Vault API endpoints are defined using regexes in instances of the SDK's framework.Path structure. However, OpenAPI does not use regexes, so a translation is performed. It is technically possible that this translation produces colliding OpenAPI paths from multiple framework.Path structures. When this happens, there has formerly been no diagnostic, and one result silently overwrites the other in a map. As a result of this, several operations are currently accidentally missing from the Vault OpenAPI, which is also the trigger for https://github.com/hashicorp/vault-client-go/issues/180. This PR adds a log message, to help catch such accidents so that they can be fixed. Much of the PR is propagating a logger to the point where it is needed, and adjusting tests for the API change. With current Vault, this will result in the following being logged each time a request is made which triggers OpenAPI generation: ``` [WARN] secrets.identity.identity_0cd35e4d: OpenAPI spec generation: multiple framework.Path instances generated the same path; last processed wins: path=/mfa/method [WARN] secrets.identity.identity_0cd35e4d: OpenAPI spec generation: multiple framework.Path instances generated the same path; last processed wins: path=/mfa/method/totp [WARN] secrets.identity.identity_0cd35e4d: OpenAPI spec generation: multiple framework.Path instances generated the same path; last processed wins: path=/mfa/method/okta [WARN] secrets.identity.identity_0cd35e4d: OpenAPI spec generation: multiple framework.Path instances generated the same path; last processed wins: path=/mfa/method/duo [WARN] secrets.identity.identity_0cd35e4d: OpenAPI spec generation: multiple framework.Path instances generated the same path; last processed wins: path=/mfa/method/pingid ``` I will submit a further PR to fix the issue - this one is just to add the diagnostic.
This commit is contained in:
@@ -374,7 +374,7 @@ func (p *Path) helpCallback(b *Backend) OperationFunc {
|
||||
}
|
||||
}
|
||||
doc := NewOASDocument(vaultVersion)
|
||||
if err := documentPath(p, b.SpecialPaths(), requestResponsePrefix, b.BackendType, doc); err != nil {
|
||||
if err := documentPath(p, b, requestResponsePrefix, doc); err != nil {
|
||||
b.Logger().Warn("error generating OpenAPI", "error", err)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user