Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Having issue with accessing directory inside a repository having same name as username #8603

Closed
2 of 7 tasks
hiteshnayak305 opened this issue Oct 20, 2019 · 3 comments · Fixed by #8604
Closed
2 of 7 tasks

Comments

@hiteshnayak305
Copy link

hiteshnayak305 commented Oct 20, 2019

Description

accessing folders inside repository with same name as user name gives error 500.
...

Screenshots

image
image

@mrsdizzie
Copy link
Member

Migrating this to view logs suggest problem is unrelated to username but nil reference with new GPG code added recently:

2019/10/20 16:37:36 ...les/context/panic.go:35:1() [E] PANIC:: runtime error: invalid memory address or nil pointer dereference
        /usr/local/opt/go/libexec/src/runtime/panic.go:82 (0x40447d0)
                panicmem: panic(memoryError)
        /usr/local/opt/go/libexec/src/runtime/signal_unix.go:390 (0x40445ff)
                sigpanic: panicmem()
        /Users/mrsdizzie/.go/src/code.gitea.io/gitea/models/gpg_key.go:684 (0x4bb116c)
                ParseCommitWithSignature: log.Error("Error getting default public gpg key: %v", err)
        /Users/mrsdizzie/.go/src/code.gitea.io/gitea/routers/repo/view.go:184 (0x4f3225f)
                renderDirectory: ctx.Data["LatestCommitVerification"] = models.ParseCommitWithSignature(latestCommit)
        /Users/mrsdizzie/.go/src/code.gitea.io/gitea/routers/repo/view.go:455 (0x4f37882)
                renderCode: renderDirectory(ctx, treeLink)
        /Users/mrsdizzie/.go/src/code.gitea.io/gitea/routers/repo/view.go:395 (0x4f36d91)
                Home: renderCode(ctx)

@zeripath
Copy link
Contributor

OK, I think I understand what's happened here. The stack trace implies that L684 here is the cause - but actually it's wrong the cause is coming from L685

gitea/models/gpg_key.go

Lines 682 to 685 in c8f3146

defaultGPGSettings, err := c.GetRepositoryDefaultPublicGPGKey(false)
if err != nil {
log.Error("Error getting default public gpg key: %v", err)
} else if defaultGPGSettings.Sign {

The defaultGPGSettings is nil. But how can that be?

gitea/modules/git/commit.go

Lines 503 to 508 in c8f3146

func (c *Commit) GetRepositoryDefaultPublicGPGKey(forceUpdate bool) (*GPGSettings, error) {
if c.repo == nil {
return nil, nil
}
return c.repo.GetDefaultPublicGPGKey(forceUpdate)
}

c.repo must be nil so this code will return nil, nil.

@zeripath
Copy link
Contributor

Now c.repo being nil implies it is an unattached commit. It absolutely should be associated with a repository otherwise we cannot examine whether it was signed by the default key.

So there's another bug that this is revealing in:

func (tes Entries) GetCommitsInfo(commit *Commit, treePath string, cache LastCommitCache) ([][]interface{}, *Commit, error) {

In particular:

// Retrieve the commit for the treePath itself (see above). We basically
// get it for free during the tree traversal and it's used for listing
// pages to display information about newest commit for a given path.
var treeCommit *Commit
if treePath == "" {
treeCommit = commit
} else if rev, ok := revs[""]; ok {
treeCommit = convertCommit(rev)
}
return commitsInfo, treeCommit, nil

Where at L74 the coerced commit doesn't gain a reference to the underlying repository
So that needs fixing and although L685 is responsible for the panic it was a good thing because we'd have great difficulty tracking down this bug without it!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants