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

Gitlab mirgration: invalid memory address or nil pointer #18434

Closed
anbraten opened this issue Jan 27, 2022 · 1 comment · Fixed by #18450
Closed

Gitlab mirgration: invalid memory address or nil pointer #18434

anbraten opened this issue Jan 27, 2022 · 1 comment · Fixed by #18450
Labels

Comments

@anbraten
Copy link
Contributor

Gitea Version

1.17.0+dev-47-g8038610a4

Git Version

No response

Operating System

No response

How are you running Gitea?

services:
        gitea-database:
          image: postgres:12.6-alpine
          restart: always
          environment:
            POSTGRES_USER: gitea
            POSTGRES_PASSWORD: "{{ gitea_database_password }}"
            POSTGRES_DB: gitea
            PGDATA: /var/lib/postgresql/data/pgdata
          volumes:
            - /var/lib/postgresql/gitea/pgdata:/var/lib/postgresql/data/pgdata

        gitea:
          image: gitea/gitea:{{ gitea_version }}
          restart: always
          ports:
            - "3022:22"
          volumes:
            - /opt/gitea:/data
            - /etc/timezone:/etc/timezone:ro
            - /etc/localtime:/etc/localtime:ro
          depends_on:
            - gitea-database
          environment:
            USER_UID: 1000
            USER_GID: 1000
            GITEA__database__DB_TYPE: postgres
            GITEA__database__HOST: gitea-database:5432
            GITEA__database__NAME: gitea
            GITEA__database__USER: gitea
            GITEA__database__PASSWD: "{{ gitea_database_password }}"
          networks:
            - default
            - web-proxy

Database

PostgreSQL

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

https://gist.github.com/anbraten/17a91226dbca85be5dae8a9541da4523

Description

Getting an error while gitea tries to migrate pull-requests from Gitlab:

PANIC during runMigrateTask[3] by DoerID[4] to RepoID[3] for OwnerID[5]: runtime error: invalid memory address or nil pointer dereference

Screenshots

No response

@zeripath
Copy link
Contributor

CreatedAt: *approvals.UpdatedAt,

Is where the stacktrace it's pointing to.

Clearly in this case the approvals.UpdatedAt pointer is nil and so dereferencing it produces a npe.

approvals itself must not be nil as the other lines would fail. Clearly the code here has assumed that this value would always be set even though the pointer should have indicated that it was potentially not.

I guess the simplest thing to do is to check if the time is present before dereferencing it but this likely means that the rest of the migration code has assumed things that it probably shouldn't have - so it could do with a check-up.

realaravinth added a commit to realaravinth/gitea that referenced this issue Jan 30, 2022
Fallback to created_at if that the case and to time.Now() if it is
also missing.

Fixes: go-gitea#18434

Co-authored-by: Loïc Dachary <[email protected]>

Conflicts:
	services/migrations/gitlab.go
	trivial context conflict because var reviews became reviews := in 1.17
6543 pushed a commit that referenced this issue Jan 30, 2022
Fallback to created_at if that the case and to time.Now() if it is
also missing.

Fixes: #18434

Co-authored-by: Loïc Dachary <[email protected]>

Conflicts:
	services/migrations/gitlab.go
	trivial context conflict because var reviews became reviews := in 1.17
@go-gitea go-gitea locked and limited conversation to collaborators Apr 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants