• 
      

    Fix some bugs in authentication to Forgejo servers.

    Review Request #15131 — Created June 23, 2026 and submitted

    Information

    Review Board
    release-8.x

    Reviewers

    The Forgejo authentication path had a few issues, which this change
    fixes:

    • get_http_credentials was returning a header key as per the base
      HostingServiceClient docstring, but this should have been headers.
      I've fixed both the bug in the Forgejo client as well as the incorrect
      docstring.
    • Some API errors don't include the url field, which was marked as
      required in the Pydantic schema.
    • Re-authentication ("Edit Credentials") was broken because it would
      still try to use the saved API key, resulting in an error about not
      having the "user:write" scope.

    Due to the fix for the re-authentication issue, I discovered that the
    HostingServiceTestCase.create_hosting_account method was aliasing
    default_account_data instead of copying it, which allowed tests to
    interfere with each other.

    • Authenticated to a new Forgejo server with both 2FA required and not.
    • Re-authenticated and saw that it correctly issued a new API token
      instead of getting a scope error.
    • Ran unit tests.
    Summary ID
    Fix some bugs in authentication to Forgejo servers.
    The Forgejo authentication path had a few issues, which this change fixes: - `get_http_credentials` was returning a `header` key as per the base `HostingServiceClient` docstring, but this should have been `headers`. I've fixed both the bug in the Forgejo client as well as the incorrect docstring. - Some API errors don't include the `url` field, which was marked as required in the Pydantic schema. - Re-authentication ("Edit Credentials") was broken because it would still try to use the saved API key, resulting in an error about not having the "user:write" scope. Due to the fix for the re-authentication issue, I discovered that the `HostingServiceTestCase.create_hosting_account` method was aliasing `default_account_data` instead of copying it, which allowed tests to interfere with each other. Testing Done: - Authenticated to a new Forgejo server with both 2FA required and not. - Re-authenticated and saw that it correctly issued a new API token instead of getting a scope error. - Ran unit tests. Fixes bug 5069.
    ouwsnxkukrtlqlumwozrotolrwqpqmxo
    Description From Last Updated

    do not use bare 'except' Column: 9 Error code: E722

    reviewbot reviewbot

    Missing a period.

    maubin maubin
    Checks run (1 failed, 1 succeeded)
    flake8 failed.
    JSHint passed.

    flake8

    david
    maubin
    1. 
        
    2. Show all issues

      Missing a period.

    3. 
        
    david
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to release-8.x (1b4678b)