Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions service/authorization/v2/authorization.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,10 @@ func (as *Service) GetDecision(ctx context.Context, req *connect.Request[authzV2

decisions, permitted, err := pdp.GetDecision(ctx, entityIdentifier, action, []*authzV2.Resource{resource})
if err != nil {
// TODO: any bad request errors that aren't 500s?
as.logger.ErrorContext(ctx, "failed to get decision", slog.String("error", err.Error()))
if errors.Is(err, access.ErrFQNNotFound) || errors.Is(err, access.ErrDefinitionNotFound) {
return nil, connect.NewError(connect.CodeNotFound, err)
}
return nil, connect.NewError(connect.CodeInternal, err)
}
resp, err := rollupSingleResourceDecision(permitted, decisions)
Expand Down Expand Up @@ -158,8 +160,10 @@ func (as *Service) GetDecisionMultiResource(ctx context.Context, req *connect.Re

decisions, allPermitted, err := pdp.GetDecision(ctx, entityIdentifier, action, resources)
if err != nil {
// TODO: any bad request errors that aren't 500s?
as.logger.ErrorContext(ctx, "failed to get decision", slog.String("error", err.Error()))
if errors.Is(err, access.ErrFQNNotFound) || errors.Is(err, access.ErrDefinitionNotFound) {
return nil, connect.NewError(connect.CodeNotFound, err)
}
return nil, connect.NewError(connect.CodeInternal, err)
}

Expand Down
2 changes: 1 addition & 1 deletion service/internal/access/v2/evaluate.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (

var (
ErrInvalidResource = errors.New("access: invalid resource")
ErrFQNNotFound = errors.New("access: attribute value FQN not found in memory")
ErrFQNNotFound = errors.New("access: attribute value FQN not found")
ErrDefinitionNotFound = errors.New("access: definition not found for FQN")
ErrFailedEvaluation = errors.New("access: failed to evaluate definition")
ErrMissingRequiredSpecifiedRule = errors.New("access: AttributeDefinition rule cannot be unspecified")
Expand Down
2 changes: 1 addition & 1 deletion service/internal/access/v2/pdp.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func (p *PolicyDecisionPoint) GetDecision(

attributeAndValue, ok := p.allEntitleableAttributesByValueFQN[valueFQN]
if !ok {
return nil, fmt.Errorf("resource value FQN not found in memory [%s]: %w", valueFQN, ErrInvalidResource)
return nil, fmt.Errorf("%w [%s]: %w", ErrFQNNotFound, valueFQN, ErrInvalidResource)
}

decisionableAttributes[valueFQN] = attributeAndValue
Expand Down
Loading