-
Notifications
You must be signed in to change notification settings - Fork 131
Description
When policy-bot has installation access to a repo, it attempts to discover the repo's policy before evaluating a PR. If no policy exists, the current behavior is to skip posting status. But if policy discovery hits a non-404 GitHub API error, policy-bot posts a failing error status. This causes noisy failures in repos that do not define a policy and do not require policy-bot as a check.
The README states that a missing policy should not post a status:
If a policy does not exist in the repository or in the shared organization
repository, `policy-bot` does not post a status check on the pull request.
The error noise in repos that don't utilize policy-bot is caused by this code in eval_context.go:
case fc.LoadError != nil:
msg := fmt.Sprintf("Error loading policy from %s", fc.Source)
logger.Warn().Err(fc.LoadError).Msg(msg)
ec.PostStatus(ctx, "error", msg)
return nil, errors.Wrapf(fc.LoadError, "failed to load policy: %s: %s", fc.Source, fc.Path)Ideally, the fix would distinguish “missing policy” from “unknown due to API error” without reporting failures in repos that don’t use policy-bot. One option is to stop posting a failing status on LoadError entirely, but where policy-bot is required, users will see policy-bot not reporting/completing for that commit, without any error details provided. Another option is to post LoadError status only for repos/branches where policy-bot is required by branch protection/rulesets.
Hoping to get some advice/discussion here from maintainers. Thanks!