[Bug] /explore/code with Elasticsearch runtime error: invalid memory address or nil pointer dereference #5994

Closed
opened 2025-11-02 06:42:11 -06:00 by GiteaMirror · 9 comments
Owner

Originally created by @jnlin on GitHub (Sep 14, 2020).

  • Gitea version (or commit ref): 1.13.0+dev-617-g8ce10fb6e
  • Git version: 2.11.0
  • Operating system: Docker
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:
template: explore/code:33:94: executing "explore/code" at <$repo.HTMLURL>: error calling HTMLURL: runtime error: invalid memory address or nil pointer dereference

Description

While trying to use explore/code, this error occurs

Screenshots

image

Originally created by @jnlin on GitHub (Sep 14, 2020). - Gitea version (or commit ref): 1.13.0+dev-617-g8ce10fb6e - Git version: 2.11.0 - Operating system: Docker - Database (use `[x]`): - [ ] PostgreSQL - [X] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [X] No - [ ] Not relevant - Log gist: ``` template: explore/code:33:94: executing "explore/code" at <$repo.HTMLURL>: error calling HTMLURL: runtime error: invalid memory address or nil pointer dereference ``` ## Description While trying to use explore/code, this error occurs ## Screenshots ![image](https://user-images.githubusercontent.com/284245/93034809-ea3dac80-f66d-11ea-83ef-f0ba6d28866f.png)
GiteaMirror added the type/bug label 2025-11-02 06:42:11 -06:00
Author
Owner

@lunny commented on GitHub (Sep 14, 2020):

Do you have a customize template?

@lunny commented on GitHub (Sep 14, 2020): Do you have a customize template?
Author
Owner

@jnlin commented on GitHub (Sep 14, 2020):

We do not use customized template. This is our app.ini

APP_NAME = My Gitea
RUN_MODE = prod
RUN_USER = git

[repository]
ROOT = /data/git/repositories

[repository.local]
LOCAL_COPY_PATH = /data/gitea/tmp/local-repo

[repository.upload]
TEMP_PATH = /data/gitea/uploads

[server]
APP_DATA_PATH    = /data/gitea
SSH_DOMAIN       = git.mydomain.work
HTTP_PORT        = 3000
ROOT_URL         = https://git.mydomain.work/
DISABLE_SSH      = false
SSH_PORT         = 22
LFS_CONTENT_PATH = /data/git/lfs
DOMAIN           = git.mydomain.work
LFS_START_SERVER = true
LFS_JWT_SECRET   = MY_JWT_SECRET
OFFLINE_MODE     = false

[database]
PATH     = /data/gitea/gitea.db
DB_TYPE  = mysql
HOST     = my_database_ip:3306
NAME     = gitea_database
USER     = gitea_username
PASSWD   = gitea_password
SSL_MODE = disable

[session]
PROVIDER_CONFIG = /data/gitea/sessions
PROVIDER        = file
GC_INTERVAL_TIME = 604800

[picture]
AVATAR_UPLOAD_PATH      = /data/gitea/avatars
DISABLE_GRAVATAR        = false
ENABLE_FEDERATED_AVATAR = true

[attachment]
ENABLED = true
PATH = /data/gitea/attachments
ALLOWED_TYPES = */*
MAX_SIZE = 100

[log]
ROOT_PATH = /data/gitea/log
MODE      = file
LEVEL     = Info

[security]
INSTALL_LOCK   = true
SECRET_KEY     = MY_SECRET_KEY
INTERNAL_TOKEN = MY_INTERNAL_TOKEN

[service]
DISABLE_REGISTRATION              = false
REQUIRE_SIGNIN_VIEW               = true
REGISTER_EMAIL_CONFIRM            = false
ENABLE_NOTIFY_MAIL                = true
ALLOW_ONLY_EXTERNAL_REGISTRATION  = true
ENABLE_CAPTCHA                    = false
DEFAULT_KEEP_EMAIL_PRIVATE        = false
DEFAULT_ALLOW_CREATE_ORGANIZATION = true
DEFAULT_ENABLE_TIMETRACKING       = true
NO_REPLY_ADDRESS                  = noreply.mydomain.work

[mailer]
ENABLED = true
HOST    = smtp.mydomain.work:25
FROM    = git@mydomain.work
USER    = 
PASSWD  = 

[openid]
ENABLE_OPENID_SIGNIN = false
ENABLE_OPENID_SIGNUP = false

[markup.ipynb]
ENABLED = true
FILE_EXTENSIONS = .ipynb
RENDER_COMMAND ="jupyter nbconvert --stdin --stdout --to html"
IS_INPUT_FILE = false

[oauth2]
JWT_SECRET = MY_JWT_SECRET

[queue]
MAX_WORKERS = 1

[indexer]
ISSUE_INDEXER_PATH = /data/gitea/indexers/issues.bleve
REPO_INDEXER_ENABLED = true
REPO_INDEXER_TYPE = elasticsearch
REPO_INDEXER_CONN_STR = http://my_es_ip:9200/
REPO_INDEXER_NAME = gitea_codes
@jnlin commented on GitHub (Sep 14, 2020): We do not use customized template. This is our `app.ini` ``` APP_NAME = My Gitea RUN_MODE = prod RUN_USER = git [repository] ROOT = /data/git/repositories [repository.local] LOCAL_COPY_PATH = /data/gitea/tmp/local-repo [repository.upload] TEMP_PATH = /data/gitea/uploads [server] APP_DATA_PATH = /data/gitea SSH_DOMAIN = git.mydomain.work HTTP_PORT = 3000 ROOT_URL = https://git.mydomain.work/ DISABLE_SSH = false SSH_PORT = 22 LFS_CONTENT_PATH = /data/git/lfs DOMAIN = git.mydomain.work LFS_START_SERVER = true LFS_JWT_SECRET = MY_JWT_SECRET OFFLINE_MODE = false [database] PATH = /data/gitea/gitea.db DB_TYPE = mysql HOST = my_database_ip:3306 NAME = gitea_database USER = gitea_username PASSWD = gitea_password SSL_MODE = disable [session] PROVIDER_CONFIG = /data/gitea/sessions PROVIDER = file GC_INTERVAL_TIME = 604800 [picture] AVATAR_UPLOAD_PATH = /data/gitea/avatars DISABLE_GRAVATAR = false ENABLE_FEDERATED_AVATAR = true [attachment] ENABLED = true PATH = /data/gitea/attachments ALLOWED_TYPES = */* MAX_SIZE = 100 [log] ROOT_PATH = /data/gitea/log MODE = file LEVEL = Info [security] INSTALL_LOCK = true SECRET_KEY = MY_SECRET_KEY INTERNAL_TOKEN = MY_INTERNAL_TOKEN [service] DISABLE_REGISTRATION = false REQUIRE_SIGNIN_VIEW = true REGISTER_EMAIL_CONFIRM = false ENABLE_NOTIFY_MAIL = true ALLOW_ONLY_EXTERNAL_REGISTRATION = true ENABLE_CAPTCHA = false DEFAULT_KEEP_EMAIL_PRIVATE = false DEFAULT_ALLOW_CREATE_ORGANIZATION = true DEFAULT_ENABLE_TIMETRACKING = true NO_REPLY_ADDRESS = noreply.mydomain.work [mailer] ENABLED = true HOST = smtp.mydomain.work:25 FROM = git@mydomain.work USER = PASSWD = [openid] ENABLE_OPENID_SIGNIN = false ENABLE_OPENID_SIGNUP = false [markup.ipynb] ENABLED = true FILE_EXTENSIONS = .ipynb RENDER_COMMAND ="jupyter nbconvert --stdin --stdout --to html" IS_INPUT_FILE = false [oauth2] JWT_SECRET = MY_JWT_SECRET [queue] MAX_WORKERS = 1 [indexer] ISSUE_INDEXER_PATH = /data/gitea/indexers/issues.bleve REPO_INDEXER_ENABLED = true REPO_INDEXER_TYPE = elasticsearch REPO_INDEXER_CONN_STR = http://my_es_ip:9200/ REPO_INDEXER_NAME = gitea_codes ```
Author
Owner

@lunny commented on GitHub (Sep 14, 2020):

So you haven't enabled code search?

@lunny commented on GitHub (Sep 14, 2020): So you haven't enabled code search?
Author
Owner

@jnlin commented on GitHub (Sep 14, 2020):

Sorry I have the wrong version of app.ini. The correct one was updated in the previous comment.

@jnlin commented on GitHub (Sep 14, 2020): Sorry I have the wrong version of `app.ini`. The correct one was updated in the previous comment.
Author
Owner

@lunny commented on GitHub (Sep 14, 2020):

I cannot reproduce this on my macOS

@lunny commented on GitHub (Sep 14, 2020): I cannot reproduce this on my macOS
Author
Owner

@jnlin commented on GitHub (Sep 14, 2020):

I guess the problem is there is not repo id == 0 in my database

the query shown in the gitea log:

2020/09/14 03:32:08 ...elastic/v7/client.go:1421:PerformRequest() [I] POST http://10.1.0.128:9200/gitea_codes/_search [status:200, request:0.031s]
2020/09/14 03:32:08 ...m.io/xorm/core/db.go:286:afterProcess() [I] [SQL] SELECT `id`, `owner_id`, `owner_name`, `lower_name`, `name`, `description`, `website`, `original_service_type`, `original_url`, `default_branch`, `num_watches`, `num_stars`, `num_forks`, `num_issues`, `num_closed_issues`, `num_pulls`, `num_closed_pulls`, `num_milestones`, `num_closed_milestones`, `num_projects`, `num_closed_projects`, `is_private`, `is_empty`, `is_archived`, `is_mirror`, `status`, `is_fork`, `fork_id`, `is_template`, `template_id`, `size`, `is_fsck_enabled`, `close_issues_via_commit_in_any_branch`, `topics`, `avatar`, `created_unix`, `updated_unix` FROM `repository` WHERE `id` IN (?) [0] - 1.448924ms
@jnlin commented on GitHub (Sep 14, 2020): I guess the problem is there is not repo id == 0 in my database the query shown in the gitea log: ``` 2020/09/14 03:32:08 ...elastic/v7/client.go:1421:PerformRequest() [I] POST http://10.1.0.128:9200/gitea_codes/_search [status:200, request:0.031s] 2020/09/14 03:32:08 ...m.io/xorm/core/db.go:286:afterProcess() [I] [SQL] SELECT `id`, `owner_id`, `owner_name`, `lower_name`, `name`, `description`, `website`, `original_service_type`, `original_url`, `default_branch`, `num_watches`, `num_stars`, `num_forks`, `num_issues`, `num_closed_issues`, `num_pulls`, `num_closed_pulls`, `num_milestones`, `num_closed_milestones`, `num_projects`, `num_closed_projects`, `is_private`, `is_empty`, `is_archived`, `is_mirror`, `status`, `is_fork`, `fork_id`, `is_template`, `template_id`, `size`, `is_fsck_enabled`, `close_issues_via_commit_in_any_branch`, `topics`, `avatar`, `created_unix`, `updated_unix` FROM `repository` WHERE `id` IN (?) [0] - 1.448924ms ```
Author
Owner

@lunny commented on GitHub (Sep 14, 2020):

Maybe you could try to reindex your data. You can delete the index gitea_codes in your es and restart gitea

@lunny commented on GitHub (Sep 14, 2020): Maybe you could try to reindex your data. You can delete the index gitea_codes in your es and restart gitea
Author
Owner

@jnlin commented on GitHub (Sep 14, 2020):

The index was generated 9:30 GMT+8 this morning.

@jnlin commented on GitHub (Sep 14, 2020): The index was generated 9:30 GMT+8 this morning.
Author
Owner

@jnlin commented on GitHub (Sep 14, 2020):

The ID saved in Elastic is like _id:1sf_Makefile, and in the code https://github.com/go-gitea/gitea/blob/master/modules/indexer/code/elastic_search.go#L291 will parse it to int64 and return 0 to repoID.

@jnlin commented on GitHub (Sep 14, 2020): The ID saved in Elastic is like `_id:1sf_Makefile`, and in the code https://github.com/go-gitea/gitea/blob/master/modules/indexer/code/elastic_search.go#L291 will parse it to int64 and return 0 to repoID.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#5994