Skip to content
safran

Type to search. Enter opens the first result.

    GitHub Issues

    The github-issues tracker reads issues from github.com and GitHub Enterprise Server through the REST API: fields, comments, links, timeline history and search, including GitHub's own search syntax. It is read-only, and it works without a token for public repositories. This page has the profile entry, the reference forms, and the places where GitHub's model differs from a classic tracker.

    Profile entry

    - id: issues
      type: github-issues
      owner: acme
      repos: [web-app, admin-panel]
      token_env: GITHUB_TOKEN

    A ticket key is repo#number:

    safran ticket web-app#412 --comments
    safran ticket acme/web-app#412
    safran ticket https://github.com/acme/web-app/issues/412
    read-issue.ts
    import { createSafran } from "@safran/core";
    
    await using safran = await createSafran({ profile: "safran.yaml" });
    
    const { tracker, key } = safran.tickets.resolve("acme/web-app#412");
    console.log(tracker.id, key); // issues web-app#412
    
    const issue = await safran.tickets.get(key);
    console.log(issue.title, issue.status, issue.labels, issue.fields.Milestone);

    Authentication

    token_env is optional. When set, the token is sent as Authorization: Bearer; the variable must then hold a token, and a missing one is AUTH_MISSING. When the field is left out, requests are anonymous, which is enough for public repositories.

    The source names no scope. The token needs read access to the issues of the listed repositories. Without a token, a 404 is reported with an extra hint that private repositories need token_env.

    Public repositories, no token

    - id: issues
      type: github-issues
      owner: acme
      repos: [web-app]

    GitHub Enterprise Server

    - id: issues
      type: github-issues
      owner: acme
      repos: [web-app, admin-panel]
      token_env: GITHUB_TOKEN
      url: https://github.acme.test/api/v3

    url is the API root. Issue links are recognised on the web host that belongs to it.

    Configuration reference

    FieldTypeDefaultRequiredMeaning
    idstringyesName of this entry.
    type"github-issues"yesSelects this plugin.
    ownerstringyesUser or organization that owns the repositories.
    reposstring[][]noRepository names, without the owner. Empty means any repository of the owner.
    projectsstring[][]noSame meaning as repos; both lists are merged. It exists because every tracker entry has projects.
    token_envvariable namenoVariable holding a token. Leave out for public repositories.
    urlURLhttps://api.github.comnoAPI root. GitHub Enterprise Server: https://HOSTNAME/api/v3.

    Ticket references

    The canonical key is web-app#412: the repository name as configured, #, the number.

    InputWith repos: [web-app, admin-panel]With repos: [web-app]With no repos
    web-app#412web-app#412web-app#412web-app#412
    acme/web-app#412web-app#412web-app#412web-app#412
    Web-App#0412web-app#412web-app#412Web-App#412
    other/web-app#412 (another owner)not matchednot matchednot matched
    ledger#412not matchednot matchedledger#412
    #412not matchedweb-app#412not matched
    412not matchednot matchednot matched
    AB#412not matchednot matchednot matched
    https://github.com/acme/web-app/issues/412web-app#412web-app#412web-app#412
    https://api.github.com/repos/acme/web-app/issues/412web-app#412web-app#412web-app#412
    https://github.com/acme/web-app/pull/412not matchednot matchednot matched

    How it stays out of other trackers' way:

    • #412 only means something with exactly one repository. With several, or with none listed, it names no issue and is not matched.
    • A bare number is never matched. That is Azure Boards' form; Azure Boards in turn leaves #412 to this tracker, so the two can share a profile.
    • AB#412 is Azure Boards' as well, unless a repository named AB is configured here. Then both trackers claim it and the caller has to name one: issues:AB#412.
    • /pull/412 URLs are not matched. Pull request URLs belong to the code host.
    • Two github-issues entries that cover the same repository do collide. Give each entry its own repos.

    A reference that turns out to be a pull request (web-app#412 where 412 is a pull request) is still returned, as a ticket with type: "pull request": a number in a commit message does not say which of the two it means.

    What a ticket contains

    Ticket fieldSource in GitHub
    key, title, urlrepo#number, title, html_url
    typepull request for a pull request; otherwise the issue type's name, or issue
    status, statusCategoryopen → todo; closed → done. GitHub has no "in progress".
    projectThe repository name
    descriptionThe issue body (Markdown)
    labelsLabel names
    assignee, reporterThe assignee (the first one when there are several), the author
    parentThe parent issue, when the issue is a sub-issue
    resolvedAtclosed_at

    priority is not set.

    Ticket.fields

    Present only when they have a value: State reason (completed, not_planned, …), Milestone, Assignees (all logins), Comments (the count), Sub-issues (total and completed), Draft (for draft pull requests). There is no custom_fields option.

    A neutral TicketSearchQuery becomes a GitHub search query.

    Query fieldSearch query
    textEvery word quoted, followed by in:title,body
    alwaysis:issue (neutral searches never return pull requests)
    projects (or the entry's repositories when absent)One repo:acme/<name> per repository; user:acme when none are configured
    statusCategoriestodo → is:open, done → is:closed, both → no qualifier
    updatedSinceupdated:>=<ISO time>

    Results are sorted by update time, newest first. Things to know:

    • Quoting. Because every word is quoted, qualifiers (repo:, is:), negation and boolean operators typed into text stay plain words. At most GITHUB_MAX_QUERY_TEXT characters of text are used; words beyond that are dropped.
    • in_progress alone matches nothing. A search that asks only for in_progress returns an empty page without a request.
    • Projects of other trackers are ignored. In a search across all trackers with projects: ["PAY"], PAY is not a repository here; when none of the requested projects is one of this tracker's repositories, the page is empty.
    • Many repositories. Above GITHUB_MAX_REPO_QUALIFIERS repositories the search runs owner-wide (user:acme) and results are cut back to the configured repositories afterwards, so pages can be shorter than limit.
    • The search API serves at most GITHUB_SEARCH_CAP results per query; paging stops there.

    Native search syntax

    search-github.ts
    import { createSafran } from "@safran/core";
    
    await using safran = await createSafran({ profile: "safran.yaml" });
    
    const page = await safran.tickets.search({ native: "repo:acme/web-app is:issue is:open label:bug sort:updated" }, { tracker: "issues" });
    for (const item of page.items) console.log(item.key, item.type, item.title);

    native is sent as written: it is not restricted to the configured owner or repositories, and it may return pull requests. A query GitHub rejects (HTTP 400 or 422) becomes INVALID_INPUT with GitHub's message in the hint.

    • Comments are the issue's comments, 100 per page at most.
    • Links returns the parent issue; sub-issues (up to 100); cross-references from the timeline, where an issue that mentions this one is a ticket link ("referenced by") and a pull request that mentions it is a web link ("referenced by pull request"); and up to GITHUB_MAX_LINK_URLS URLs found in the issue body ("mentioned in description"). The timeline is read for at most GITHUB_MAX_TIMELINE_PAGES_FOR_LINKS pages of 100 events. The sub-issue and timeline lookups are best effort.
    • History is the issue timeline without comments: label, assignee, title, state and milestone changes, cross-references, commits and reviews. Other events appear with their event name as the field.
    • Attachments are not supported (UNSUPPORTED): files uploaded to an issue are links in its Markdown body.

    Rate limits and missing issues

    • GitHub signals a rate limit with 403 as well as 429. A 403 that carries x-ratelimit-remaining: 0 or a retry-after header is treated as the 429 it means: it is retried after the time the server names, and reported as RATE_LIMITED when retries run out.
    • 404 hides private repositories; 410 is a deleted issue. Both are reported as NOT_FOUND.
    • A repository that was renamed or moved answers with a redirect. It is followed on the same host only.

    Limits

    ConstantValueMeaning
    DEFAULT_PAGE_SIZE / MAX_PAGE_SIZE50 / 100Comments, history entries and search results per page.
    GITHUB_MAX_QUERY_TEXT200Characters of free text put into a search.
    GITHUB_MAX_REPO_QUALIFIERS30Repositories named with repo: before a search goes owner-wide.
    GITHUB_SEARCH_CAP1000Results one search can page through.
    GITHUB_MAX_LINK_URLS20URLs taken from an issue body for links.
    GITHUB_MAX_TIMELINE_PAGES_FOR_LINKS3Timeline pages read for cross-references.
    GITHUB_MAX_REPO_PAGES5Pages of 100 repositories read by listProjects when no repos are configured.

    With repos configured, listProjects answers from the profile without a request. Without them it lists the owner's repositories, leaving out archived ones and those with issues turned off.

    Known caveats

    The GitHub connectors are the only built-in ones that have been run against the live service, and only with public repositories. See verification status. One item is marked UNVERIFIED in the source:

    • GitHub Enterprise Server hosts. The web host is derived from the API URL: an api. prefix is removed (api.github.com → github.com), otherwise the API host is used as it is, which fits a server that offers the API under /api/v3 on the host of its web UI. If your server's web UI is on a different host than this rule gives, pasted issue URLs are not recognised; keys (web-app#412) still work.

    See also