authz code logs warnings about Redis returning nil values
Created by: mrnugget
- Make sure
github.com/sourcegraph/automation-testing
is cloned - Go to
http://localhost:3080/campaigns/new
- Select
Regexp search and replace
asType
- Enter the following as
Arguments
. It's only **important that thescopeQuery
matches at least one repository:
{
"scopeQuery": "automation-testing",
"regexpMatch": "this\\sis",
"textReplace": "that thou"
}
- Hit
Preview changes
What you'll see is "Preview changes complete" but no changes.
In the log output you'll see something this:
10:11:24 frontend | WARN failed to parse bytes from Redis value, value: <nil>
I tried to get a backtrace of why that happens and it looks like that
when we do a search in an Automation campaign we end up creating
repositoryResolvers
and those access the authz
code:
goroutine 176 [running]:
github.com/sourcegraph/sourcegraph/internal/rcache.(*Cache).GetMulti(0xc00202b220, 0xc001dd5d00, 0x1, 0x1, 0x0, 0x0, 0x0)
/Users/thorstenball/work/sourcegraph/internal/rcache/rcache.go:64 +0x40b
github.com/sourcegraph/sourcegraph/enterprise/cmd/frontend/internal/authz/github.(*Provider).getCachedPublicRepos(0xc001b5e870, 0x3af05a0, 0xc001fa2090, 0xc001e21818, 0x1, 0x1, 0xc001fa2150, 0x0, 0x0)
/Users/thorstenball/work/sourcegraph/enterprise/cmd/frontend/internal/authz/github/github.go:183 +0x3f5
github.com/sourcegraph/sourcegraph/enterprise/cmd/frontend/internal/authz/github.(*Provider).RepoPerms.func1(0xc001dd5ce0, 0x0, 0x0)
/Users/thorstenball/work/sourcegraph/enterprise/cmd/frontend/internal/authz/github/github.go:67 +0x144
github.com/sourcegraph/sourcegraph/enterprise/cmd/frontend/internal/authz/github.(*Provider).RepoPerms(0xc001b5e870, 0x3af05a0, 0xc001fa2090, 0x0, 0xc001e21818, 0x1, 0x1, 0x0, 0x0, 0x0, ...)
/Users/thorstenball/work/sourcegraph/enterprise/cmd/frontend/internal/authz/github/github.go:113 +0x450
github.com/sourcegraph/sourcegraph/cmd/frontend/db.authzFilter(0x3af05a0, 0xc001fa2090, 0xc001e21810, 0x1, 0x1, 0xc000000002, 0x0, 0x0, 0x0, 0x0, ...)
/Users/thorstenball/work/sourcegraph/cmd/frontend/db/repos_perm.go:187 +0x1cea
github.com/sourcegraph/sourcegraph/cmd/frontend/db.(*repos).getReposBySQL(0x4dfa4c0, 0x3af05a0, 0xc001f6e420, 0xc001f90101, 0xc001f6e6c0, 0x0, 0x0, 0x0, 0x0, 0x0)
/Users/thorstenball/work/sourcegraph/cmd/frontend/db/repos.go:202 +0x804
github.com/sourcegraph/sourcegraph/cmd/frontend/db.(*repos).List(0x4dfa4c0, 0x3af05a0, 0xc001f6e420, 0x0, 0x0, 0xc001d03530, 0x1, 0x1, 0x0, 0x0, ...)
/Users/thorstenball/work/sourcegraph/cmd/frontend/db/repos.go:334 +0x80b
github.com/sourcegraph/sourcegraph/cmd/frontend/graphqlbackend.resolveRepositories(0x3af05a0, 0xc001d431a0, 0xc001d66a60, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
/Users/thorstenball/work/sourcegraph/cmd/frontend/graphqlbackend/search.go:502 +0x1ecd
github.com/sourcegraph/sourcegraph/cmd/frontend/graphqlbackend.(*searchResolver).resolveRepositories(0xc001190cf0, 0x3af05a0, 0xc001f6e240, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
/Users/thorstenball/work/sourcegraph/cmd/frontend/graphqlbackend/search.go:313 +0xa3f
github.com/sourcegraph/sourcegraph/cmd/frontend/graphqlbackend.(*searchResolver).determineRepos(0xc001190cf0, 0x3af0560, 0xc001fb6840, 0xc001f6e180, 0xbf81cdae8bce8988, 0x1526064ba6, 0x4dd22c0, 0x0, 0x0, 0x0, ...)
/Users/thorstenball/work/sourcegraph/cmd/frontend/graphqlbackend/search_results.go:860 +0xec
github.com/sourcegraph/sourcegraph/cmd/frontend/graphqlbackend.(*searchResolver).doResults(0xc001190cf0, 0x3af0560, 0xc001fbef60, 0x0, 0x0, 0x0, 0x0, 0x0)
/Users/thorstenball/work/sourcegraph/cmd/frontend/graphqlbackend/search_results.go:969 +0x431
github.com/sourcegraph/sourcegraph/cmd/frontend/graphqlbackend.(*searchResolver).resultsWithTimeoutSuggestion(0xc001190cf0, 0x3af0560, 0xc001fbef60, 0x0, 0x0, 0x0)
/Users/thorstenball/work/sourcegraph/cmd/frontend/graphqlbackend/search_results.go:506 +0xbe
github.com/sourcegraph/sourcegraph/cmd/frontend/graphqlbackend.(*searchResolver).Results(0xc001190cf0, 0x3af0560, 0xc001fbef60, 0x0, 0x0, 0x0)
/Users/thorstenball/work/sourcegraph/cmd/frontend/graphqlbackend/search_results.go:477 +0x165
github.com/sourcegraph/sourcegraph/enterprise/internal/a8n.(*regexSearchReplace).generateDiff(0xc001af0d00, 0x3af0560, 0xc001fbef60, 0xc0017c60a0, 0x12, 0xc001adc2a0, 0x28, 0x0, 0x0, 0x0, ...)
/Users/thorstenball/work/sourcegraph/enterprise/internal/a8n/campaign_type.go:308 +0x3e3
github.com/sourcegraph/sourcegraph/enterprise/internal/a8n.runCampaignJob(0x3af0560, 0xc001fbef60, 0x326c7b0, 0xc001b47ac0, 0x3ad6220, 0xc001af0d00, 0xc001a2b110)
/Users/thorstenball/work/sourcegraph/enterprise/internal/a8n/runner.go:380 +0xabc
github.com/sourcegraph/sourcegraph/enterprise/internal/a8n.RunCampaignJobs.func1(0x3af0520, 0xc000052120, 0xc001b47ac0, 0x1e, 0xa, 0x1, 0xc001adc2a0, 0x28, 0xc0017765c0, 0x11, ...)
/Users/thorstenball/work/sourcegraph/enterprise/internal/a8n/runner.go:293 +0xce
github.com/sourcegraph/sourcegraph/enterprise/internal/a8n.(*Store).ProcessPendingCampaignJob(0xc000324d80, 0x3af0520, 0xc000052120, 0xc0003f0370, 0x0, 0x0, 0x0)
/Users/thorstenball/work/sourcegraph/enterprise/internal/a8n/store.go:143 +0x50d
github.com/sourcegraph/sourcegraph/enterprise/internal/a8n.RunCampaignJobs.func2()
/Users/thorstenball/work/sourcegraph/enterprise/internal/a8n/runner.go:302 +0x112
created by github.com/sourcegraph/sourcegraph/enterprise/internal/a8n.RunCampaignJobs
/Users/thorstenball/work/sourcegraph/enterprise/internal/a8n/runner.go:314 +0x2f2
The problem comes from this function here:
It's called with different keys and some return a value and others don't. I checked their values in Redis directly:
$ redis-cli
127.0.0.1:6379> GET v2:githubAuthz:https://github.com/:r:MDEwOlJlcG9zaXRvcnk0MTI4ODcwOA==
"{\"Public\":true,\"TTL\":10800000000000}"
127.0.0.1:6379> GET v2:githubAuthz:https://github.com/:r:MDEwOlJlcG9zaXRvcnkxOTM4Mzc5MTA=
(nil)
It seems like the code can't handle nil
values.