320: MSSQL: loadEnvFile and MSSQL_URL parsing #344
No reviewers
Labels
No labels
bug
chore
documentation
enhancement
feature
ready
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
david/pi-extensions-and-skills!344
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/issue-320/mssql-loadenvfile-and-mssql-url-parsing"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
320: MSSQL: loadEnvFile and MSSQL_URL parsing
Implements 320.
Generated in 51s.
Review findings
Decisions: reject empty user/database and multi-segment paths (return null).# Review Findings — 320
Summary
I fixed every finding except the
dotenvimport note.extractMssqlConnInfonow has tests.parseMssqlUrlreturnsnullfor an empty user, an empty database or a multi-segment path, and each case has a test. I renamed the misleading test and asserted it returnsnull. I removed theexistsSynccall fromloadEnvFile.node --test extensions/mssql/env.test.tspasses all 23 tests. The repo has no build or lint script, and I did not run the fullnpm testsuite. I left thedotenvnote unresolved because it asked only for confirmation and needed no change. The namespace import works in the current test run.Critical
High
extractMssqlConnInfois exported and holds the case-insensitiveMSSQL_URLlookup plus parse, butenv.test.tsnever exercises it. Suggested fix: add tests for a present URL (including a lowercase key), an absent key returningnull, an empty-string value returningnull, and an invalid URL returningnull.Medium
parseMssqlUrlaccepts a URL with an empty username (mssql://h/db) or an empty database (mssql://u@h) and returnsuser: ""ordatabase: "".ConnInfotypes both as required strings, so callers could attempt a connection with empty credentials or an empty database. Suggested fix: decide the intended behaviour and either returnnullwhenuserordatabaseis empty, or make the fields optional. Add tests for whichever you choose.parsed.pathname.slice(1)leaves any extra path segments in the database name (/db/extrabecomesdb/extra). Suggested fix: reject or truncate a multi-segment path, with a test.Low
invalidUrl_doesNotThrowMessageContainingPasswordonly asserts that the call doesn't throw, so its name overstates what it checks. Suggested fix: rename it toinvalidUrl_doesNotThrow, or assert the result isnull.loadEnvFileusesexistsSyncand thenreadFileSync, which is a small TOCTOU gap. It is harmless here because the read is already wrapped in a try/catch. Suggested fix: drop theexistsSynccall and rely on the try/catch alone.dotenvis imported with a namespace import. Suggested fix: confirmdotenv.parseresolves under Node ESM type-stripping. It works in the current test run, so this is only a note.