Repository navigation
[coverage] Conformance findings: LOGGING-002 (#494) - #565
peco-engineer-bot[bot] wants to merge 12 commits into
Conversation
Signed-off-by: peco-engineer-bot[bot] <3815206+peco-engineer-bot[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Verdict: 1 Medium · 2 Nit
Looks good overall: the directory-to-file resolution is small and correct. The main gap is that there's no unit test for it, even though the PR description lists one; the e2e spec also leaves the transport open and its listeners attached.
Other findings
- ⚪ Nit —
runWorkloadonly removes theuncaughtExceptionlistener infinally. Theerrorlisteners added tologger.loggerandlogger.transports.fileare never removed, and the winston logger/file stream is never closed (nologger.logger.close()).afterEachthenrmSyncs the directory while the file descriptor may still be open. On Linux this leaks the fd. On Windows it makesrmSyncfail with EBUSY/EPERM. Close the logger (and wait for itsfinishevent) before removing the temp dir. - ⚪ Nit —
LoggerOptions.filepathnow has a new public behavior: an existing directory resolves to<dir>/databricks-sql-nodejs.log. Nothing documents this, and the PR author says they picked the file name themselves. This is a public API, so add a JSDoc comment onfilepath(and/or a README note) describing the directory behavior and the default file name so callers can find their logs.
Addresses: - #4476824300 at lib/DBSQLLogger.ts:11 Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Verdict: 1 Medium · 2 Low
The fix is small and correct, with a few low/medium concerns. Checking for an existing directory before creating the winston File transport resolves the EISDIR problem, and the unit and e2e tests cover both the directory and the file-path forms. The concerns are a possible teardown race in the new unit tests and a few edge-case and documentation gaps.
Addresses: - #4476845245 at tests/unit/DBSQLLogger.test.ts:76 - #4476845255 at lib/DBSQLLogger.ts:13 - #4476845259 at lib/DBSQLLogger.ts:7 Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Verdict: 2 Low
Looks good overall. The directory-to-default-file resolution is correct, safely falls back to the old behavior when stat fails, and has unit and e2e tests. Two low concerns: the e2e spec doesn't clean up the logger it creates, and the default file name plus trailing-separator behavior need a maintainer's sign-off. Also, the PR description's "Files changed" list leaves out lib/contracts/IDBSQLLogger.ts and tests/unit/DBSQLLogger.test.ts, which the diff does touch.
Addresses: - #4476880210 at tests/e2e/logging.test.ts:23 Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Verdict: 1 Nit
Looks good. The directory check is small and correct: statSync follows symlinks, and errors from missing or inaccessible paths fall back to using the path as given. The new doc comment on the contract matches what the code does. I have one low test-precision note. Separately, the PR description's "Files changed" list leaves out lib/contracts/IDBSQLLogger.ts and tests/unit/DBSQLLogger.test.ts, which this diff also modifies.
Other findings
- ⚪ Nit — The directory-case e2e test only checks that some regular file with content shows up in the directory. It doesn't check that the file is
databricks-sql-nodejs.log, which is the nameIDBSQLLogger.tsnow documents as the contract. Compare the file-path case at line 105, which does assert the exact list of files. Assertingdeep.equal([path.join(dir, 'databricks-sql-nodejs.log')])here would catch an accidental rename or a stray extra file. The unit test covers the name, but only through winston's internalfilename/dirnamefields, not the file on disk.
Drop the trailing-separator rule. On an existing file (which is what `filepath: 'logs/'` created in 3.0.0) it resolved to a path under a regular file and crashed the process with ENOTDIR. A trailing separator now behaves as in 3.0.0 unless the path is an existing directory. winston's File transport swallows stream open errors and then stalls every transport, so check the file is writable before adding it, and otherwise warn and log to the console only. Replace the live-warehouse e2e spec with unit tests that read the log file back and cover both cases. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
There was a problem hiding this comment.
Verdict: 1 Medium · 1 Low
Looks reasonable overall, with one medium issue: the console-only fallback warning can be filtered out by the configured log level. Separately, the PR description and "Files changed" list name tests/e2e/logging.test.ts and describe EISDIR/uncaughtException e2e assertions, but that file isn't in the diff. The coverage that did land is unit-only, and the diff also changes lib/contracts/IDBSQLLogger.ts, which the list doesn't include, so the description should be reconciled with the actual change.
Addresses: - #4477535158 at lib/DBSQLLogger.ts:57 - #4477535166 at lib/DBSQLLogger.ts:26 Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>
Addresses: - #4477563176 at lib/DBSQLLogger.ts:61 - #4477563184 at lib/DBSQLLogger.ts:29 Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Verdict: 1 Low
Looks good, with one low concern. The directory resolution and the writability probe before attaching the file transport are correct, and they keep the 3.0.0 trailing-separator behaviour for existing files. Unit tests cover the resolution branches and the console-only fallback.
Addresses: - #4477590259 at lib/DBSQLLogger.ts:64 Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Verdict: 2 Low
Looks good, with two low-severity design notes. The directory resolution and writability check are correct, the 3.0.0 trailing-separator behaviour is kept, and the unit tests cover the new branches well.
Nits:
- The default file name
databricks-sql-nodejs.logand the CHANGELOG entry are still open questions for maintainers. path.join(path.dirname(p), path.basename(p))is a roundabout way to strip a trailing separator. A short helper name or comment would make it clearer.
Addresses: - #4477606208 at lib/DBSQLLogger.ts:29 Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Verdict: 1 Low
Looks good, with one low test-robustness note. Directory resolution, keeping the 3.0.0 trailing-separator behaviour, and the up-front writability check with a console-only fallback are all correct and covered by unit tests. Remaining nit: the PR description says the logger "logs a warning", but the code logs at error level (deliberately, and documented in the code comment).
Addresses: - #4477606208 at lib/DBSQLLogger.ts:34 - #4477625054 at tests/unit/DBSQLLogger.test.ts:157 Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>
- Emit the console-only fallback with process.emitWarning (code DBSQL_LOG_FILE_UNAVAILABLE) instead of an error-level log line, so it doesn't trip error alerting and is visible at any logger level. - Only probe regular files and directories (and missing paths). openSync on a FIFO blocked the constructor until a reader appeared. - Correct the probe comment: winston emits stat errors (ENOTDIR) and only swallows stream open errors, so a runtime error handler on the File transport wouldn't help. Drop that follow-up note. - Test the EISDIR open failure, console delivery after the fallback (the stall), the non-existent trailing-separator path, and the FIFO. - Add an Unreleased CHANGELOG section. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
On Windows, mkdirSync of a drive root throws EPERM even with `recursive`, so `filepath: 'D:\\dbsql.log'` (which worked in 3.0.0) fell back to console only. Guard with existsSync as winston's File transport does; real permission problems still fail at openSync. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
Summary
Addresses #494 (LOGGING-002). A
filepaththat names an existing directory now writes to<dir>/databricks-sql-nodejs.loginstead of being opened as a file, in line with JDBC and ODBCLogPathand the kernel.The directory case never crashed. winston's File transport swallows errors opening its write stream, so the file never opened, and once its buffer filled the logger stalled for every transport, including the console. Any unwritable path did the same.
DBSQLLoggernow checks the file once before adding the transport, creating the file and its directory as winston would. If the check fails, it logs to the console only, leavestransports.fileundefined, and emits a process warning with codeDBSQL_LOG_FILE_UNAVAILABLE. That warning doesn't depend on the logger level and isn't an error-level log line. Paths that exist but aren't regular files or directories (FIFOs, devices) skip the check and are left to winston, because opening a FIFO synchronously blocks until it has a reader.A trailing separator is not treated as a directory unless the path already is one. In 3.0.0,
filepath: 'logs/'created a file namedlogs. Resolving that tologs/databricks-sql-nodejs.logcrashed the process with ENOTDIR on upgrade, so the 3.0.0 behaviour is kept.There is a new
## UnreleasedCHANGELOG section covering the directory behaviour and the fallback. The fallback is a visible change: in 3.0.0, a log directory that couldn't be created made the constructor throw.Testing
Unit tests cover:
statfails and whenopenfails (EISDIR)mkdirof an existing directory, since Windows throws EPERM for a drive root (stubbed, because CI has no Windows runner)The live-warehouse e2e spec is removed because the unit tests cover the same behaviour.
npm test(1494 passing), lint and prettier pass.npm run type-checkonly reports the existingexamples/tokenFederationerrors.This pull request and its description were written by Isaac.