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

Errors on /api/v1/user/repos #4565

Closed
2 of 7 tasks
duckbrain opened this issue Jun 16, 2017 · 4 comments
Closed
2 of 7 tasks

Errors on /api/v1/user/repos #4565

duckbrain opened this issue Jun 16, 2017 · 4 comments
Labels
💊 bug Something isn't working priority: critical Oh damn, fix it now!

Comments

@duckbrain
Copy link

Description

While trying to use Gogs with Drone 0.7 or manually using the path that Drone is trying to access.

GET https://jon.duckdns.org/gogs/api/v1/user/repos

I get a variety of responses. I get either a 403 or a 500 response code and I get either a blank response or the following JSON:

{"message":"Only signed in user is allowed to call APIs."}

I am logged into the browser and accessing the URL from the browser. It does seem that /api/v1/user does work correctly. Restarting Gogs will sometimes make the JSON response come back until it goes back to the empty responses. I believe the switch coincides with the panics in the log.

It does not seem that changing REQUIRE_SIGNIN_VIEW makes any difference.

@502647092
Copy link

@duckbrain MayBe You Need give token or Basic Auth Like This
image

@duckbrain
Copy link
Author

It looks like it's a bug. I found that the panic was happening because of a nil pointer here:

/models/repo.go#314

So I did some querying of the database

MariaDB [gogs2]> SELECT * FROM repository WHERE is_fork=1;
+-----+----------+------------+-------+--------------------------------------------------+---------+----------------+-------------+-----------+-----------+------------+-------------------+-----------+------------------+----------------+-----------------------+------------+---------+-----------+---------+---------+---------------------+---------------------+-------------+---------------+-------------------------+-------------------------+--------------+----------------------+-------------------+--------------+--------------+------------------------+----------------------+-----------+-------------------+---------------------+
| id  | owner_id | lower_name | name  | description                                      | website | default_branch | num_watches | num_stars | num_forks | num_issues | num_closed_issues | num_pulls | num_closed_pulls | num_milestones | num_closed_milestones | is_private | is_bare | is_mirror | is_fork | fork_id | created             | updated             | enable_wiki | enable_issues | enable_external_tracker | external_tracker_format | enable_pulls | enable_external_wiki | external_wiki_url | created_unix | updated_unix | external_tracker_style | external_tracker_url | size      | allow_public_wiki | allow_public_issues |
+-----+----------+------------+-------+--------------------------------------------------+---------+----------------+-------------+-----------+-----------+------------+-------------------+-----------+------------------+----------------+-----------------------+------------+---------+-----------+---------+---------+---------------------+---------------------+-------------+---------------+-------------------------+-------------------------+--------------+----------------------+-------------------+--------------+--------------+------------------------+----------------------+-----------+-------------------+---------------------+
|  50 |        7 | ldss       | ldss  | LDS Scriptures port to native command line in Go |         | master         |           1 |         0 |         0 |          0 |                 0 |         0 |                0 |              0 |                     0 |          0 |       0 |         0 |       1 |       2 | 2016-01-04 19:07:31 | 2016-03-11 07:38:52 |           0 |             0 |                       0 |                         |            0 |                    0 |                   |   1451934451 |   1494990776 | numeric                |                      | 107675648 |              NULL |                NULL |
| 160 |        1 | kimai      | kimai |                                                  |         | master         |           1 |         0 |         0 |          0 |                 0 |         0 |                0 |              0 |                     0 |          1 |       0 |         0 |       1 |     155 | NULL                | NULL                |           0 |             0 |                       0 |                         |            0 |                    0 |                   |   1474662911 |   1474663090 | numeric                | NULL                 |  58913792 |              NULL |                NULL |
+-----+----------+------------+-------+--------------------------------------------------+---------+----------------+-------------+-----------+-----------+------------+-------------------+-----------+------------------+----------------+-----------------------+------------+---------+-----------+---------+---------+---------------------+---------------------+-------------+---------------+-------------------------+-------------------------+--------------+----------------------+-------------------+--------------+--------------+------------------------+----------------------+-----------+-------------------+---------------------+

MariaDB [gogs2]> SELECT * FROM repository WHERE id in (2,155);
+-----+----------+------------+-------+--------------------------------------------------+---------+----------------+-------------+-----------+-----------+------------+-------------------+-----------+------------------+----------------+-----------------------+------------+---------+-----------+---------+---------+---------------------+---------------------+-------------+---------------+-------------------------+-------------------------+--------------+----------------------+-------------------+--------------+--------------+------------------------+----------------------+----------+-------------------+---------------------+
| id  | owner_id | lower_name | name  | description                                      | website | default_branch | num_watches | num_stars | num_forks | num_issues | num_closed_issues | num_pulls | num_closed_pulls | num_milestones | num_closed_milestones | is_private | is_bare | is_mirror | is_fork | fork_id | created             | updated             | enable_wiki | enable_issues | enable_external_tracker | external_tracker_format | enable_pulls | enable_external_wiki | external_wiki_url | created_unix | updated_unix | external_tracker_style | external_tracker_url | size     | allow_public_wiki | allow_public_issues |
+-----+----------+------------+-------+--------------------------------------------------+---------+----------------+-------------+-----------+-----------+------------+-------------------+-----------+------------------+----------------+-----------------------+------------+---------+-----------+---------+---------+---------------------+---------------------+-------------+---------------+-------------------------+-------------------------+--------------+----------------------+-------------------+--------------+--------------+------------------------+----------------------+----------+-------------------+---------------------+
|   2 |        1 | ldss       | ldss  | LDS Scriptures port to native command line in Go |         | master         |           2 |         0 |         1 |         44 |                42 |         5 |                4 |              4 |                     0 |          0 |       0 |         0 |       0 |       0 | 2015-10-23 19:32:54 | 2016-04-06 18:20:48 |           1 |             1 |                       0 |                         |            1 |                    0 |                   |   1445628774 |   1495778981 | numeric                |                      | 64939008 |              NULL |                NULL |
| 155 |        9 | kimai      | kimai |                                                  |         | master         |           2 |         0 |         1 |          1 |                 1 |         1 |                0 |              0 |                     0 |          1 |       0 |         0 |       0 |       0 | NULL                | NULL                |           1 |             1 |                       0 |                         |            1 |                    0 |                   |   1471569584 |   1472858856 | numeric                | NULL                 | 58901504 |              NULL |                NULL |
+-----+----------+------------+-------+--------------------------------------------------+---------+----------------+-------------+-----------+-----------+------------+-------------------+-----------+------------------+----------------+-----------------------+------------+---------+-----------+---------+---------+---------------------+---------------------+-------------+---------------+-------------------------+-------------------------+--------------+----------------------+-------------------+--------------+--------------+------------------------+----------------------+----------+-------------------+---------------------+

As you can see, where two forks in the database. The IDs for both of their fork_id's did refer to valid repositories. It looks like the ORM populates repo.BaseRepo, so I'm not sure why it's coming back as nil.

The Kimai fork was mine and I didn't need it, so I deleted it through the Gogs interface, but left the ldss fork alone. The endpoint is now working.

@unknwon Is it expected that BaseRepo can be nil? If so, I can submit a pull request to check if it's nil, to solve this issue, otherwise, where should one look for solving the issue?

@unknwon unknwon added the 💊 bug Something isn't working label Jun 21, 2017
@unknwon unknwon added this to the 0.12 milestone Jun 21, 2017
@unknwon unknwon added the priority: critical Oh damn, fix it now! label Jun 21, 2017
@unknwon unknwon added the status: needs feedback Tell me more about it label Jun 21, 2017
@unknwon
Copy link
Member

unknwon commented Jun 21, 2017

Patch has pushed to fix this issue, please test on master branch or https://try.gogs.io.

@duckbrain
Copy link
Author

Yep. That did the trick. Thanks Unknwon!

@unknwon unknwon removed the status: needs feedback Tell me more about it label Jun 25, 2017
@unknwon unknwon removed this from the 0.13 milestone Nov 26, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
💊 bug Something isn't working priority: critical Oh damn, fix it now!
Projects
None yet
Development

No branches or pull requests

3 participants