Skip to content

Commit

Permalink
Call out nil return for now
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Wilson committed Aug 2, 2024
1 parent 00fa861 commit 63bd015
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion audit/entry_formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ func clone[V any](s V) (V, error) {
// an audit Auth.
// tokenRemainingUses should be the client token remaining uses to include in auth.
// This usually can be found in logical.Request.ClientTokenRemainingUses.
// NOTE: Will return nil auth and error if the supplied auth is nil.
// The caller should check the returned value for nil before using it.
func newAuth(auth *logical.Auth, tokenRemainingUses int) (*Auth, error) {
if auth == nil {
return nil, nil
Expand Down Expand Up @@ -336,6 +338,8 @@ func newAuth(auth *logical.Auth, tokenRemainingUses int) (*Auth, error) {

// newRequest takes a logical.Request and namespace.Namespace, transforms and
// aggregates them into an audit Request.
// NOTE: Will return nil request and error if the supplied request is nil.
// The caller should check the returned value for nil before using it.
func newRequest(req *logical.Request, ns *namespace.Namespace) (*Request, error) {
if req == nil {
return nil, nil
Expand Down Expand Up @@ -397,6 +401,8 @@ func newRequest(req *logical.Request, ns *namespace.Namespace) (*Request, error)
// newResponse takes a logical.Response and logical.Request, transforms and
// aggregates them into an audit Response.
// isElisionRequired is used to indicate that response 'Data' should be elided.
// NOTE: Will return nil response and error if the supplied response is nil.
// The caller should check the returned value for nil before using it.
func newResponse(resp *logical.Response, req *logical.Request, isElisionRequired bool) (*Response, error) {
if resp == nil {
return nil, nil
Expand Down Expand Up @@ -538,7 +544,7 @@ func (f *entryFormatter) createEntry(ctx context.Context, a *AuditEvent) (*Entry

var resp *Response
if a.Subtype == ResponseType {
shouldElide := f.config.elideListResponses && req.Operation == logical.ListOperation
shouldElide := f.config.elideListResponses && req != nil && req.Operation == logical.ListOperation
resp, err = newResponse(data.Response, data.Request, shouldElide)
if err != nil {
return nil, fmt.Errorf("cannot convert request: %w", err)
Expand Down

0 comments on commit 63bd015

Please sign in to comment.