GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — projector(github): GITHUB_APP_PRIVATE_KEY 'base64 of PEM' form fails — decodePem never unwraps it, appJwt throws Invalid keyData · Issue #1529 · developing-today/code

projector(github): GITHUB_APP_PRIVATE_KEY 'base64 of PEM' form fails — decodePem never unwraps it, appJwt throws Invalid keyData #1529

New issue
Copy link
New issue
Copy link
Closed
#2921
Closed
projector(github): GITHUB_APP_PRIVATE_KEY 'base64 of PEM' form fails — decodePem never unwraps it, appJwt throws Invalid keyData#1529
#2921
Copy link
Assignees
dezren39
Labels
app/pm-stackpm-stack (Pad/Grist) in developing-today/codekind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobtask/triageQueue packet kind: verify, reproduce, and route this item

Description

@dezren39
dezren39
opened on Oct 28, 2026
Issue body actions

projector: GITHUB_APP_PRIVATE_KEY documented "base64 of PEM" form fails — decodePem never unwraps it

Summary

pm-stack/projector/src/github.ts documents GITHUB_APP_PRIVATE_KEY as "PEM (or base64 of PEM)" (line 6), but the base64-of-PEM form does not work: appJwt throws Invalid keyData at key import. Only raw PEM text and base64-of-DER actually work today, and the tests only cover base64-of-DER — so the documented input form most operators would produce (base64-encoding the .pem file GitHub gives them, e.g. for a one-line env var) is silently broken.

Evidence

decodePem (github.ts:16-23):

function decodePem(pem: string): string {
  const trimmed = pem.replace(/-----[^-]+-----/g, "").replace(/\s/g, "");
  if (/^[A-Za-z0-9+/]+=*$/.test(trimmed) && !trimmed.includes("PRIVATE")) {
    // already base64 of the DER key
    return trimmed;
  }
  return trimmed;
}

Trace for base64-of-PEM input:

  1. Input is base64 of the whole PEM text — it contains no ----- markers, so the strip is a no-op; the string is pure base64, so the regex branch returns it unchanged.
  2. appJwt (github.ts:66-67) then does a single Buffer.from(b64, "base64") — which yields the PEM text bytes, not DER.
  3. importRsaKey feeds those ASCII bytes to WebCrypto as PKCS#8 (and then as PKCS#1-wrapped) → both fail with "Invalid keyData".

Verified behavior (reproduced on the laptop against the current code):

  • plain PEM text → works (header/footer stripped, body is the DER base64)
  • base64 of DER → works
  • base64 of PEM → FAIL Invalid keyData

Test gap: pm-stack/projector/test/github.test.ts:5-9 builds its "key formats" fixtures by exporting DER and base64-encoding that (privateKey.export({ type, format: "der" })). No fixture ever passes PEM text or base64-of-PEM, so the documented contract is untested in exactly the form that's broken.

Why it matters

The projector's GitHub App auth is how it self-heals beyond webhook delivery. An operator who follows the header comment and stores the key base64-encoded (the standard way to put a PEM in an env var or secret store) gets a projector that cannot authenticate at all, with an error that points at the key data rather than the encoding — the worst kind of config failure to diagnose.

Acceptance criteria

  • appJwt succeeds with all three input forms of the same key: raw PEM text, base64 of DER, and base64 of PEM (both PKCS#1 "RSA PRIVATE KEY" and PKCS#8 PEM variants).
  • Fix direction: make decodePem actually decode — if the input is base64 whose decoded text starts with -----BEGIN, treat the decoded text as PEM and extract its body (one recursive/iterative unwrap is enough); keep the existing DER and raw-PEM behavior unchanged.
  • Tests in test/github.test.ts cover PEM-text and base64-of-PEM fixtures (generate the key, export format: "pem", pass it raw and base64-encoded) alongside the existing DER controls.
  • No change to the env var names or the documented contract — the code is brought up to the doc, not the other way around.

Notes

  • Found by new-issue-creator-code-b (run 2026-10-27 15:20 CDT), which verified the reproduction but timed out before filing; filed by the coordinator from its verified report and re-checked against source at github.ts:6,16-23,66-67 and test/github.test.ts:5-20.
  • Dedup: gh issue search (open + closed) for decodePem, base64 PEM, GITHUB_APP_PRIVATE_KEY in this repo returned no existing issue.

Activity

Next
  1. dezren39
    added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/triageQueue packet kind: verify, reproduce, and route this item
    status/needs-triageNot yet triaged; needs a first look
    source/creatorFiled by the new-issue-creator job
    priority/normalOrdinary priority (the default)
    queue/queuedHas a queued queue task
    app/pm-stackpm-stack (Pad/Grist) in developing-today/code
    on Oct 28, 2026
  2. developing-today commented on Oct 28, 2026

    @developing-today
    developing-todayBot
    on Oct 28, 2026 – with developing.today
    Contributor
    More actions

    CODE-586

  3. github-actions
    assigned
    dezren39
    on Oct 28, 2026
  4. dezren39 commented on Oct 28, 2026

    @dezren39
    dezren39
    on Oct 28, 2026
    MemberAuthor
    More actions

    🤖 Agent note · filed

    • Agent: new-issue-creator job (lane B, slug new-issue-creator-code-b) — verification by the lane-B run; filing completed by the coordinator after that run timed out pre-filing
    • Session / ID: cron job new-issue-creator-code-b, run 2026-10-27 15:20 CDT (filing completed 2026-10-27 ~19:02 CDT)
    • Found via: filed this run
    • Task: Filed after verifying that pm-stack/projector/src/github.ts decodePem (:16-23) never unwraps base64-of-PEM: the documented GITHUB_APP_PRIVATE_KEY form "PEM (or base64 of PEM)" (github.ts:6) base64-decodes once in appJwt (:66-67) to PEM text, which WebCrypto then rejects as Invalid keyData. Reproduced on the laptop: plain PEM OK, base64-of-DER OK, base64-of-PEM FAIL. Tests (test/github.test.ts:5-20) only ever feed base64-of-DER fixtures, so the documented form is untested. Enqueued as a triage packet to repo-health-code-pilot.
    • Expectation: triage (effort s) confirms and routes the fix: decodePem unwraps base64-of-PEM (decode → PEM text → strip body), existing forms unchanged, PEM-text and base64-of-PEM fixtures added to test/github.test.ts for both PKCS#1 and PKCS#8.
    • Links: packet hidden_files/packet-1529.json · body hidden_files/issue-code-projector-decodepem-b64pem-body.md
  5. dezren39
    added
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    status/in-progressQueue worker lifecycle state
    and removed
    status/needs-triageNot yet triaged; needs a first look
    queue/queuedHas a queued queue task
    on Oct 28, 2026
  6. 2 remaining items

  7. dezren39
    added
    queue/queuedHas a queued queue task
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    status/in-progressQueue worker lifecycle state
    and removed
    status/in-progressQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    queue/queuedHas a queued queue task
    on Oct 28, 2026
  8. dezren39 commented on Oct 31, 2026

    @dezren39
    dezren39
    on Oct 31, 2026
    MemberAuthor
    More actions

    🤖 Agent note · picked up

    • Agent: queue worker (repo-worker-code), openchamber scheduled lane
    • Session / ID: queue task 1804 (small_fix)
    • Found via: queue claim
    • Task: Fix projector(github): GITHUB_APP_PRIVATE_KEY 'base64 of PEM' form fails — decodePem never unwraps it, appJwt throws Invalid keyData #1529 — decodePem base64-of-PEM unwrap in pm-stack/projector/src/github.ts + PEM fixtures (pkcs1+pkcs8, raw and base64-encoded)
    • Expectation: effort s; done = PR opened with base64-of-PEM single unwrap, DER behavior byte-identical, github.test.ts green
    • Links: issue projector(github): GITHUB_APP_PRIVATE_KEY 'base64 of PEM' form fails — decodePem never unwraps it, appJwt throws Invalid keyData #1529
  9. dezren39
    added a commit that references this issue on Oct 31, 2026

    Merge pull request #2921 from developing-today/queue/1804-1529-decode…

    48f7c86
  10. dezren39
    closed this as completedin #2921on Oct 31, 2026
  11. dezren39
    removed
    status/in-progressQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    on Oct 31, 2026
  12. dezren39 commented on Oct 31, 2026

    @dezren39
    dezren39
    on Oct 31, 2026
    MemberAuthor
    More actions

    🤖 Agent note · done — fixed & merged

    • Agent: queue worker (repo-worker-code), openchamber scheduled lane
    • Session / ID: queue task 1804 (small_fix)
    • Fix: PR fix(projector): unwrap base64-of-PEM in decodePem (#1529) #2921 merged as 48f7c86 — decodePem single-unwrap of base64-of-PEM; raw-PEM and base64-of-DER byte-identical
    • Tests: github.test.ts 8/8 pass (4 new PEM fixtures); full suite delta clean vs origin/main (libsql dep failures pre-existing, unrelated)
    • Labels: removed work/assigned, queue/claimed, status/in-progress (terminal state)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @dezren39
    dezren39

Labels

app/pm-stackpm-stack (Pad/Grist) in developing-today/codekind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobtask/triageQueue packet kind: verify, reproduce, and route this item

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.