Comments (11)
yeah this one's on me, so only right I notified you of a fix :) i found it as part of creating a private repo on codeberg and my buildbot instance exploding. I will push the fix with the PR im working on rn for GitHub app support (ill make a separate PR)
from buildbot-nix.
Maybe the API is not used correctly here.
So it first fetches all repositories:
f"{config.instance_url}/api/v1/user/repos?limit=100"
And than it uses this api call:
f"{config.instance_url}/api/v1/repos/{repo['owner']['login']}/{repo['name']}/topics",
However one difference I see is that it uses http header for authentication:
headers={"Authorization": f"token {config.token}"},
Does curl -H "Authorization: token $token" https://git.domain.com/api/v1/repos/buildbot-mannuk/nix-config/topics
work?
from buildbot-nix.
Maybe forking the project and add some print
statement to see if the token is actually what you would expect, can help here. I haven't tested it with private repository so far as it's just now on opensource projects.
from buildbot-nix.
Thanks for coming back and trying to help.
I am on my phone atm so responses might be a little basic.
I've edited the first post to make it clear that yes the curl command worked fine from the buildbot node.
I checked on matrix chat and it seems me adding private is irrelevant as the api works regardless of being private and if the token is correct it should see the repo.
I noted on github you have a 'user' which might populate the user/owner of the repo in an api call, but we do not appear to have access to that user for gitea? Eg where do you get 'user' and 'owner' from in your above api calls?
It seems your method with headers is the preffered way now, I will try that with curl.
from buildbot-nix.
The owner
comes from the information returned by /api/v1/user/repos?limit=100
, so I would assume that this is the correct one?
from buildbot-nix.
Does
curl -H "Authorization: token $token" https://git.domain.com/api/v1/repos/buildbot-mannuk/nix-config/topics
work?
Yes this works, it returns;
{"topics":["buildbot-mannuk"]}
This is the one that fails for me (not sure why yet)
> f"{config.instance_url}/api/v1/user/repos?limit=100"
from buildbot-nix.
So after some investigation I loosened the CORS and headers settings I was using and now have the initial API working fine from within the buildbot node.....so both API calls now work with the token set in the header;
->> curl -X 'GET' \
'https://git.domain.com/api/v1/user/repos?limit=100' \
-H 'accept: application/json' \
-H 'Authorization: token < token >'
[{"id":20,"owner":{"id":14,"login":"buildbot-mannuk","login_name":"","full_name":"","email":"","avatar_url":"https://git.domain.com/avatars/...","language":"","is_admin":false,"last_login":"0001-01-01T00:00:00Z","created":"2024-05-05T17:33:30+01:00","restricted":false,"active":false,"prohibit_login":false,"location":"","website":"","description":"","visibility":"private","followers_count":0,"following_count":0,"starred_repos_count":0,"username":"buildbot-mannuk"},"name":"nix-config","full_name":"/nix-config","description":"","empty":false,"private":true,"fork":false,"template":false,"parent":null,"mirror":false,"size":2227,"language":"Nix","languages_url":"https://git.domain.com/api/v1/repos/buildbot-mannuk/nix-config/languages","html_url":"https://git.domain.com/buildbot-mannuk/nix-config","url":"https://git.domain.com/api/v1/repos/buildbot-mannuk/nix-config","link":"","ssh_url":"[email protected]:buildbot-mannuk/nix-config.git","clone_url":"https://git.domain.com/buildbot-mannuk/nix-config.git","original_url":"","website":"","stars_count":0,"forks_count":0,"watchers_count":2,"open_issues_count":0,"open_pr_counter":0,"release_counter":0,"default_branch":"main","archived":false,"created_at":"2023-11-11T23:21:36Z","updated_at":"2024-05-05T17:35:26+01:00","archived_at":"1970-01-01T01:00:00+01:00","permissions":{"admin":true,"push":true,"pull":true},"has_issues":false,"has_wiki":false,"has_pull_requests":true,"has_projects":true,"has_releases":true,"has_packages":true,"has_actions":false,"ignore_whitespace_conflicts":false,"allow_merge_commits":true,"allow_rebase":true,"allow_rebase_explicit":true,"allow_squash_merge":true,"allow_rebase_update":true,"default_delete_branch_after_merge":false,"default_merge_style":"merge","default_allow_maintainer_edit":false,"avatar_url":"","internal":false,"mirror_interval":"","mirror_updated":"0001-01-01T00:00:00Z","repo_transfer":null}]
This is the full error buildbot-nix gives me;
Failed to reload project list: Traceback (most recent call last):
File "/nix/store/lpi16513bai8kg2bd841745vzk72475x-python3-3.11.9/lib/python3.11/threading.py", line 1045, in _bootstrap_inner
self.run()
File "/nix/store/lpi16513bai8kg2bd841745vzk72475x-python3-3.11.9/lib/python3.11/threading.py", line 982, in run
self._target(*self._args, **self._kwargs)
File "/nix/store/9hhsjc8fisn7np61njgaqs8i7c4m6p85-python3-3.11.9-env/lib/python3.11/site-packages/twisted/_threads/_threadworker.py", line 49, in work
task()
File "/nix/store/9hhsjc8fisn7np61njgaqs8i7c4m6p85-python3-3.11.9-env/lib/python3.11/site-packages/twisted/_threads/_team.py", line 192, in doWork
task()
--- <exception caught here> ---
File "/nix/store/9hhsjc8fisn7np61njgaqs8i7c4m6p85-python3-3.11.9-env/lib/python3.11/site-packages/twisted/python/threadpool.py", line 269, in inContext
result = inContext.theWork() # type: ignore[attr-defined]
File "/nix/store/9hhsjc8fisn7np61njgaqs8i7c4m6p85-python3-3.11.9-env/lib/python3.11/site-packages/twisted/python/threadpool.py", line 285, in <lambda>
inContext.theWork = lambda: context.call( # type: ignore[attr-defined]
File "/nix/store/9hhsjc8fisn7np61njgaqs8i7c4m6p85-python3-3.11.9-env/lib/python3.11/site-packages/twisted/python/context.py", line 117, in callWithContext
return self.currentContext().callWithContext(ctx, func, *args, **kw)
File "/nix/store/9hhsjc8fisn7np61njgaqs8i7c4m6p85-python3-3.11.9-env/lib/python3.11/site-packages/twisted/python/context.py", line 82, in callWithContext
return func(*args, **kw)
File "/nix/store/9hhsjc8fisn7np61njgaqs8i7c4m6p85-python3-3.11.9-env/lib/python3.11/site-packages/buildbot_nix/gitea_projects.py", line 251, in reload_projects
refresh_projects(self.config, self.project_cache_file)
File "/nix/store/9hhsjc8fisn7np61njgaqs8i7c4m6p85-python3-3.11.9-env/lib/python3.11/site-packages/buildbot_nix/gitea_projects.py", line 290, in refresh_projects
topics: list[str] = http_request(
File "/nix/store/9hhsjc8fisn7np61njgaqs8i7c4m6p85-python3-3.11.9-env/lib/python3.11/site-packages/buildbot_nix/common.py", line 79, in http_request
raise HttpError(msg) from e
buildbot_nix.common.HttpError: Request for GET https://git.domain.com/api/v1/repos/buildbot-mannuk/nix-config/topics failed with 403 Forbidden: {"message":"Only signed in user is allowed to call APIs."}
I have tried deleting the /var/lib/buildbot directories and started fresh, and reset the dB, if that would likely make any différance, but it didn't, the error persists :-/
For completeness;
->> curl -H "Authorization: token < token >" https://git.domain.com/api/v1/repos/buildbot-mannuk/nix-config/topics
response;
{"topics":["buildbot-mannuk"]}
from buildbot-nix.
I am going to close this for now as setting up a new forgejo instance to try this with.
I believe its due to Gitea being behind traefik, but putting time into a new fully nix setup, rather than try and further debug the old docker one.
from buildbot-nix.
I did find a bug, where inside the reload-gitea-projects
it was passing a function pointer instead of a token, ill push the patch soon and then you can retry, it may have been that
from buildbot-nix.
I did find a bug, where inside the
reload-gitea-projects
it was passing a function pointer instead of a token, ill push the patch soon and then you can retry, it may have been that
Hey @MagicRB thank you for coming back on this one as after a good while trying I still haven't got buildbot linked to gitea :-/ and haven't had more time to try and debug.
As I could ssh into the nodes and curl the gitea API successfully, but using the same token failed in buildbot, I suspected a token related issue, so I will certainly give it another try once you have had time to merge it :)
from buildbot-nix.
Nothings on anyone, its open source, so no issue there, but if it solves my problem, it might help my sanity :)
Chatting in the forgejo matrix room, I understood private repos were not relevant as if the token has access, private or not, the api will work.
That said, it might of course be relevant in build bot somehow :)
from buildbot-nix.
Related Issues (20)
- Gitea support at all? HOT 8
- Hercules-effects support
- Support other binary caches next to cachix HOT 7
- Rework GITHUB_TOKEN support so we only need a github app
- Schedule Builds according to Nix Dependencies HOT 4
- "Register gcroot" doesn't work well with the pull-request flow HOT 4
- Fine-Grained Personal Access Tokens don't need `repo:admin` HOT 5
- buildbot-nix access control for private repos HOT 6
- Add integration tests
- UX: Links back to the repos
- Better error handling on boot HOT 2
- Support rendering HTML outputs
- Parse the Nix evaluation warnings and display them in the UI HOT 1
- Build the frontend from source
- Org members cannot stop builds HOT 6
- pull based CI runs
- Reporting issue when there are too many checks HOT 10
- JWT token creation is unreliable HOT 14
- Generic OIDC auth HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from buildbot-nix.