Preserve cancellation after profile lookups

This commit is contained in:
2026-08-25 02:06:47 +00:00
parent 67f788b1e2
commit 3d99483219
2 changed files with 26 additions and 2 deletions

View File

@@ -33,7 +33,7 @@ func (r *resolvingRepository) GetProfile(ctx context.Context, id string) (*domai
return nil, err
}
profile, err := r.source.GetProfile(ctx, requestedID)
profile, err := r.getRawProfile(ctx, requestedID)
if err != nil {
return nil, err
}
@@ -61,7 +61,7 @@ func (r *resolvingRepository) GetProfile(ctx context.Context, id string) (*domai
return nil, fmt.Errorf("%w: profile inheritance chain exceeds %d profiles: %s", ErrInvalidProfile, maximumProfileChainLength, joinProfileChain(chainIDs, baseID))
}
base, err := r.source.GetProfile(ctx, baseID)
base, err := r.getRawProfile(ctx, baseID)
if err != nil {
if errors.Is(err, ErrProfileNotFound) {
return nil, fmt.Errorf("%w: base profile %q is missing in chain %s", ErrInvalidProfile, baseID, joinProfileChain(chainIDs, baseID))
@@ -88,6 +88,17 @@ func (r *resolvingRepository) GetProfile(ctx context.Context, id string) (*domai
return resolved, nil
}
func (r *resolvingRepository) getRawProfile(ctx context.Context, id string) (*domain.ExecutionProfile, error) {
profile, err := r.source.GetProfile(ctx, id)
if err != nil {
return nil, err
}
if err := ctx.Err(); err != nil {
return nil, err
}
return profile, nil
}
func joinProfileChain(chain []string, next string) string {
return strings.Join(append(append([]string(nil), chain...), next), " -> ")
}