Skip to content

Enabling branch protection rules disables api requests without authorization token #10738

Closed
@mattiasbpersson

Description

@mattiasbpersson

Description

When enabling "Branch Protection for Branch" you are no longer able to request the api for:
https://try.gitea.io/api/v1/repos/mattiasbpersson/test/branches

Example code run in script console in Jenkins:

import groovy.json.JsonSlurper

def REPO = "led-deploy"
def DEFAULT_BRANCH = "master"

List<String> branches = [DEFAULT_BRANCH]

URL url = new URL("https://try.gitea.io/api/v1/repos/mattiasbpersson/test/branches")

final slurper = new JsonSlurper()
def json = slurper.parse(url)
json.each { item ->
  branches << item.name
}

If branch protection is disabled master branch is returned. If it is enabled you get:
java.io.IOException: Server returned HTTP response code: 500 for URL: https://try.gitea.io/api/v1/repos/mattiasbpersson/test/branches
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    modifies/apiThis PR adds API routes or modifies themtype/bug

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions