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

API GetRepos() return empty list if no active repos exist #658

Merged
merged 1 commit into from
Jan 3, 2022

Conversation

jdoubleu
Copy link
Contributor

@jdoubleu jdoubleu commented Jan 3, 2022

When there are no repositories yet, you can observe the following error in the JavaScript console:

TypeError: null has no properties
    loadRepos http://localhost:8000/assets/index.3d82d057.js:1
    C http://localhost:8000/assets/vendor.82796ebf.js:5
    setup http://localhost:8000/assets/Repos.1bb0497d.js:1
    ...

This is due to the fact, that the /api/user/repos returns the literal string "null".

I still think the API returns the wrong value. I would expect it to return a []*model.Repo which would yield an empty array [] if empty and not null. Otherwise we might need to catch a similar case in every API call in the client?

@6543 6543 added bug Something isn't working ui frontend related labels Jan 3, 2022
@6543 6543 added this to the 0.15.0 milestone Jan 3, 2022
@6543 6543 requested a review from anbraten January 3, 2022 16:18
@6543
Copy link
Member

6543 commented Jan 3, 2022

api should return a empty json list ... - yes we need to improve the whole api bit more 😓

@jdoubleu jdoubleu force-pushed the fix-empty-repo-list branch from 5a6e460 to 2078fc8 Compare January 3, 2022 17:55
@jdoubleu
Copy link
Contributor Author

jdoubleu commented Jan 3, 2022

Fixed it on the server-side and removed the client-side patch.

@6543 6543 changed the title fix javascript error when repo list is empty API GetRepos() return empty list if no active repos exist Jan 3, 2022
@6543 6543 added server and removed ui frontend related labels Jan 3, 2022
@6543 6543 merged commit abd3d1d into woodpecker-ci:master Jan 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working server
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants