Skip to content

Fourteen files read process.env directly, and nothing validates it #338

Open

Description

@Miracle656

Background

src/config.ts exists and is 333 lines, reading process.env 34 times. It does
no validation — no schema, no zod, despite zod already being a dependency used
for route validation. And 14 other files under src/ read process.env
directly, bypassing it entirely, among them src/db.ts, src/app.ts,
src/index.ts, src/api/admin.ts and src/bazaar/rateLimit.ts.

The failure mode is a misspelled or missing variable becoming undefined, then
a default, then a service that starts cleanly and behaves wrongly. A numeric
limit read as undefined silently becomes NaN in arithmetic. Nothing fails
until a price is wrong.

What to build

  • One validated config module as the single source: parse and validate the whole
    environment once at startup with zod, and fail to start on anything invalid.
  • Types derived from the schema, so a typo in a config key is a compile error.
  • Replace the 14 direct reads with imports from it.
  • Every variable documented in .env.example. The repo has a drift guard that
    checks this — run it.
  • Required-in-production variables must be required, not silently defaulted.

Acceptance criteria

  • process.env is read in exactly one module
  • Invalid or missing required configuration fails at startup with a message naming the variable
  • Config values are typed from the schema
  • .env.example documents every variable and the drift guard passes
  • A numeric variable that is not a number is rejected rather than becoming NaN

Drips Wave · Complexity: Intermediate · 150 points


Repo: Divinity-Labs/Lens. Node + TypeScript, Fastify, Prisma on Postgres,
Redis for queues, Prometheus via prom-client.

Run the tests: npm test. The tests are vitest, not jest. Running jest
against this repo reports "66 suites, 0 tests" and means nothing. A single file
is npx vitest run src/__tests__/yourfile.test.ts.

Load test (prices) is already failing on main and has been for some
time. It is not your PR that broke it. Every other check should be green.

This service prices real assets on Stellar mainnet. A number that is wrong
is worse than a number that is missing, because a caller cannot tell the
difference. Prefer failing loudly over returning a plausible value.

Never elide an address, a contract id or a key in code, a comment or a test
fixture.
A previous batch wrote a shortened contract id in an issue text and
five contributors invented plausible-looking ids to fill the gap. Write the
whole thing or do not write it at all.

The house pattern for an outbound deadline already exists — see
src/alerts/delivery.ts, which passes signal: AbortSignal.timeout(10_000) to
fetch. Where an issue below asks for a timeout, copy that, do not invent a
second convention.


Required: Before submitting, join the contributor Telegram so your work can be tracked and counted toward the Stellar Wave: https://t.me/+fxHXq8f1SwlkZDBk

Activity

  1. Miracle656 commented on Oct 16, 2026

    @Miracle656
    CollaboratorAuthor

    Coordination note: #113 "Restructure config.ts into a per-network config map" (assigned to @Belzabeem) also rewrites src/config.ts.

    They are different changes — #113 is about the shape of the per-network configuration, this one is about validating the environment once at startup and removing the 14 direct process.env reads elsewhere in src/ — but they land in the same file and will conflict if written blind.

    Check #113's state before starting, and coordinate on who goes first. If #113 has already landed, rebase onto it and keep its structure.

  2. Jossy-ossy commented on Oct 16, 2026

    @Jossy-ossy
    Contributor

    @Jossy-ossy has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

    I am a reliable and motivated applicant who values quality, commitment, and timely delivery. I am ready to understand the requirements of this issue, work diligently, and provide the best results I can. I am committed to giving my best and ensuring satisfactory outcomes.

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @Jossy-ossy to this issue.

  3. Ranjeet2063 commented on Oct 16, 2026

    @Ranjeet2063
    Contributor

    @Ranjeet2063 has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

    Ready to ship immediately! Focus: Full-Stack Software Engineering & Core Architecture for "Fourteen files read process.env directly, and noth". Plan: Deliver clean, modular code following the repository's established design patterns and TypeScript/Rust conventions. Guaranteed 100% green CI & test coverage. Zero hand-holding. SLA: clean PR in 1-2h. Track record: 166+ merged PRs in Web3 (OSS score 83, Top 2%).

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @Ranjeet2063 to this issue.

  4. Stanley471 commented on Oct 16, 2026

    @Stanley471
    Contributor

    @Stanley471 has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

    Hello maintainer, I'd like to work on this issue. I'll start by reviewing the existing code and conventions in the relevant files before making changes, so my implementation stays consistent with the rest of the codebase. I'll cover the requirements and acceptance criteria as listed, add tests where applicable, and verify everything builds/passes locally before opening the PR

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @Stanley471 to this issue.

  5. drips-wave commented on Oct 16, 2026

    @drips-wave

    Congratulations, @Jossy-ossy! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on October 22, 2026.

    🧑‍💻 @Jossy-ossy: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.

    Warning

    When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.

    🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.

    🌊 Happy Wave 🌊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions