Skip to content

enforce: warn when app has zero installations#845

Open
arpitjain099 wants to merge 1 commit into
ossf:mainfrom
arpitjain099:fix/warn-no-installations
Open

enforce: warn when app has zero installations#845
arpitjain099 wants to merge 1 commit into
ossf:mainfrom
arpitjain099:fix/warn-no-installations

Conversation

@arpitjain099

Copy link
Copy Markdown

Fixes #294

Problem

When the Allstar GitHub App is authenticated but installed in zero organizations, EnforceAll (in pkg/enforce/enforce.go) lists installations, logs count:0 and EnforceAll complete at INFO level, and then iterates an empty slice without enforcing anything. There is no signal that the app simply was not installed anywhere, which is the most common cause. The issue reporter spent time debugging this because invalid PRIVATE_KEY / APP_ID both produce clear errors, but the much more likely "authenticated but not installed" case is silent.

Change

After the existing Enforcing policies on installations. log, when len(insts) == 0, emit a log.Warn stating that authentication succeeded but no installations were found, that no policies will be enforced, and pointing the operator at the install step (app Settings page -> Install App tab). The logging matches the surrounding zerolog style (Str("area", "bot")).

Test

Added TestEnforceAllNoInstallations, which mocks getAppInstallations to return an empty slice, captures the zerolog global logger into a buffer, and asserts a warn-level entry mentioning "no installations were found" is produced. It also confirms getAppInstallationRepos is not called and the results map is empty. I verified the test is a real regression test: it fails against the unpatched enforce.go and passes with the fix.

$ go test ./pkg/enforce/...
ok  	github.com/ossf/allstar/pkg/enforce	1.296s

gofmt -l and go vet ./pkg/enforce/... are both clean on the changed files.

Note on docs

The original issue also suggested adding a step to operator.md documenting that the app must be installed into an org. I kept this PR scoped to the code fix and its test so the behavior change is easy to review on its own. Happy to follow up with the docs update (or fold it in here) if maintainers prefer.

This commit is DCO signed off (Signed-off-by).

When the Allstar GitHub App is authenticated but installed in zero
organizations, EnforceAll logged count:0 and EnforceAll complete at
Info level and exited silently, leaving operators with no hint that
the app simply was not installed anywhere.

Emit a Warn-level log in that case stating that authentication
succeeded but no installations were found, and point at the missing
install step. Add a regression test that exercises the
zero-installations path and asserts the warning is produced.

Fixes ossf#294

Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
@arpitjain099 arpitjain099 requested a review from a team as a code owner June 2, 2026 23:16
@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Jun 2, 2026
@github-actions

Copy link
Copy Markdown

This pull request has been marked stale because it has been open for 10 days with no activity

@github-actions github-actions Bot added the Stale label Jun 13, 2026
@arpitjain099

Copy link
Copy Markdown
Author

Still active on this. Let me know if there are any changes you'd like or if a maintainer can take a look when they get a chance.

@github-actions github-actions Bot removed the Stale label Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

App doesn't report an error when it exists, but is not installed in any organisations

1 participant