Title: projector(config): PORT and GITHUB_APP_INSTALL_ID are never validated — PORT=0 silently binds a random port, typos crash with a RangeError naming neither variable, and a garbage install ID is silently treated as unset · Issue #2172 · developing-today/code · GitHub
Open Graph Title: projector(config): PORT and GITHUB_APP_INSTALL_ID are never validated — PORT=0 silently binds a random port, typos crash with a RangeError naming neither variable, and a garbage install ID is silently treated as unset · Issue #2172 · developing-today/code
X Title: projector(config): PORT and GITHUB_APP_INSTALL_ID are never validated — PORT=0 silently binds a random port, typos crash with a RangeError naming neither variable, and a garbage install ID is silently treated as unset · Issue #2172 · developing-today/code
Description: Summary The pm-stack projector's two numeric environment inputs are parsed with bare Number() and never validated: PORT (pm-stack/projector/src/index.ts:6): const port = Number(env.PORT ?? 7801) is passed straight to Bun.serve in pm-stac...
Open Graph Description: Summary The pm-stack projector's two numeric environment inputs are parsed with bare Number() and never validated: PORT (pm-stack/projector/src/index.ts:6): const port = Number(env.PORT ?? 7801) is...
X Description: Summary The pm-stack projector's two numeric environment inputs are parsed with bare Number() and never validated: PORT (pm-stack/projector/src/index.ts:6): const port = Number(env.PORT ?? 7801...
Opengraph URL: https://github.com/developing-today/code/issues/2172
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"projector(config): PORT and GITHUB_APP_INSTALL_ID are never validated — PORT=0 silently binds a random port, typos crash with a RangeError naming neither variable, and a garbage install ID is silently treated as unset","articleBody":"## Summary\n\nThe pm-stack projector's two numeric environment inputs are parsed with bare `Number()` and never validated:\n\n- `PORT` (`pm-stack/projector/src/index.ts:6`): `const port = Number(env.PORT ?? 7801)` is passed straight to `Bun.serve` in `pm-stack/projector/src/server.ts` (`serve(db, env, port)`). `PORT=0` silently binds a **random ephemeral port** while every consumer expects 7801; `PORT=abc` / `99999` / `-1` / `4870.5` crash at startup with a Bun `RangeError` that names neither `PORT` nor the projector.\n- `GITHUB_APP_INSTALL_ID` (`pm-stack/projector/src/github.ts:121`): `installId = Number(env.GITHUB_APP_INSTALL_ID)`. `'abc'` becomes `NaN`, which is falsy, so the configured installation is **silently skipped as if unset** — reconcile then falls back to `GITHUB_TOKEN` or throws `no_github_credentials_for_\u003crepo>`, an error that blames credentials when the real problem is a typo'd install ID. `'12.5'` is truthy and is interpolated verbatim into `https://api.github.com/app/installations/12.5/access_tokens`, producing a misleading `installation_token_failed_404`.\n\n## Evidence (verified this run on main `c58507a3`)\n\n- `pm-stack/projector/src/index.ts:6` — the only parse of `PORT`; no range/integer check anywhere in `src/` (grep).\n- `pm-stack/projector/src/github.ts:121` — the only parse of `GITHUB_APP_INSTALL_ID`; the result is used at `:122` (`&& installId`) and `:125` (URL interpolation).\n- Sandbox Bun probe of the exact pattern (`port = Number(raw)`, then `Bun.serve({port, hostname:\"127.0.0.1\"})`):\n - `\"abc\"` → `NaN` → `RangeError [ERR_OUT_OF_RANGE]: The value of \"options.port\" is out of range. It must be an integer. Received NaN`\n - `\"99999\"` → `RangeError ... must be >= 0 and \u003c= 65535. Received 99999`\n - `\"-1\"` → same RangeError; `\"4870.5\"` → `RangeError ... must be an integer. Received 4870.5`\n - `\"0\"` → **bound port 36647** (random ephemeral) and reported as listening; `\"7801\"` → bound 7801 (control)\n- Install-ID coercion probe: `Number(\"abc\")` → `NaN`, `!!NaN === false` (so the `:122` gate treats a configured-but-garbage ID exactly like an unset one); `Number(\"12.5\")` → `12.5`, truthy, used verbatim in the access-token URL.\n- No test covers either input: `pm-stack/projector/test/` has no `PORT` / `GITHUB_APP_INSTALL_ID` validation cases (grep).\n- The fleet already has the strict precedent: `bin/proxy-port.mjs` (`parseProxyPort`) rejects non-integer / out-of-range ports with an error naming the variable.\n\n## Why it matters\n\nThe projector is the PM stack's GitHub→database intake; its consumers (the aggregator's live source, per `pm-stack/projector/README.md`) find it at the expected port. A one-character typo in `PORT` either makes the service silently live on a random port (unit healthy, data stale, nothing in the log points at the cause) or kills it with a runtime error that does not name the variable to fix. A typo in `GITHUB_APP_INSTALL_ID` silently downgrades or breaks reconcile auth with an error that sends the operator to check the wrong credential.\n\n## Acceptance criteria\n\n- [ ] A `PORT` that is not an integer in 1–65535 (including `0`, unless 0 is made an explicit documented opt-in) fails at startup with an error naming `PORT`, the offending value, and the valid range — before any bind.\n- [ ] A `GITHUB_APP_INSTALL_ID` that is not a positive integer fails (or at minimum logs a loud warning naming the variable and value) instead of being silently treated as unset; a fractional value is never interpolated into the access-token URL.\n- [ ] Defaults unchanged: unset `PORT` → 7801; unset `GITHUB_APP_INSTALL_ID` → existing discovery/token fallback path.\n- [ ] Tests cover `'abc'`, `'0'`, `'-1'`, `'99999'`, `'4870.5'` for `PORT` and `'abc'` / `'12.5'` for the install ID, plus the unset defaults.\n\n## Dedup / distinctness\n\n- #1547 (OPEN) is the projector's read-API `?limit=` validation — a different input surface (query param → SQL) in the same service.\n- #2161 (OPEN) is the aggregator's `PM_AGG_PORT`/`PM_AGG_HOSTS` in a different service (`pm-stack/aggregator/src/config.ts`); this issue is the projector's own entry-point/auth env parsing (`src/index.ts`, `src/github.ts`). If triage prefers, the fix patterns should be shared, but the code paths and failure modes are separate.\n- #1529 (OPEN) is `GITHUB_APP_PRIVATE_KEY` PEM decoding in the same file — unrelated to the install-ID number parse.\n","author":{"url":"https://github.com/dezren39","@type":"Person","name":"dezren39"},"datePublished":"2026-10-29T07:28:42Z","url":"https://github.com/developing-today/code/issues/2172"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:463068c1-426f-be5f-9920-99e789492989 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8584:128099:E55A7C:1357579:6B06525A |
| html-safe-nonce | d8f0ebdf54714e27638127b0ecc99ddfc03b98a2ae844b511dcc7a5f0474bc3f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NTg0OjEyODA5OTpFNTVBN0M6MTM1NzU3OTo2QjA2NTI1QSIsInZpc2l0b3JfaWQiOiIyMjg2NDMyMTI1MzU4MzMwNDU4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 5067e598431aaf815cfc1012dc113b57fd65d67658779c5a4192f0f0431fd4c1 |
| hovercard-subject-tag | issue:6095052510 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/developing-today/code/2172/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ce3d842b40ca2d26f0db4d716cb8e7aec930a3b8a643b9ceec8144d7ddf4776a/developing-today/code/issues/2172 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ce3d842b40ca2d26f0db4d716cb8e7aec930a3b8a643b9ceec8144d7ddf4776a/developing-today/code/issues/2172 |
| og:image:alt | Summary The pm-stack projector's two numeric environment inputs are parsed with bare Number() and never validated: PORT (pm-stack/projector/src/index.ts:6): const port = Number(env.PORT ?? 7801) is... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dezren39 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 772b6997ca4daa0428dd49a25d76052e765555ae560fe9c88517eb828bbd861e |
| turbo-cache-control | no-preview |
| go-import | github.com/developing-today/code git https://github.com/developing-today/code.git |
| octolytics-dimension-user_id | 26439447 |
| octolytics-dimension-user_login | developing-today |
| octolytics-dimension-repository_id | 627308783 |
| octolytics-dimension-repository_nwo | developing-today/code |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 627308783 |
| octolytics-dimension-repository_network_root_nwo | developing-today/code |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f1f9a08f7c769a37f1dfc18ad43d463c222a7eea |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width