Fix CDS extractor database diagnostics to point to source-relative file paths#239
Merged
data-douser merged 6 commits intomainfrom Oct 20, 2025
Merged
Conversation
Creates the `.github/instructions/` directory and adds the first `*.instructions.md` file intended for use by Copilot (or other LLM) in reviewing and maintaining code for this repository.
Updates the CDS extractor source code and unit tests in order to ensure that tool-level diagnostics only ever use relative paths.
Improves the diagnostic messages created by the CDS extractor reports for the edge case where some file path is associated with a diagnostic warning or error but is not a path within the source root directory that the CDS extractor was configured to scan. This change attempts to continue to prevent path injection and path traversal attacks for any diagnostics generated by the CDS extractor while ensuring the unlinkability of this edge case is explained to any user viewing such diagnostics. We don't expect to encounter situations where a diagnostic error or warning is reported for any file outside of the scanned source root directory, but we want to handle such situations well and we do so here by improving the text of our diagnostic message to the user without giving the user a link to a non-repo file.
jeongsoolee09
approved these changes
Oct 20, 2025
Contributor
jeongsoolee09
left a comment
There was a problem hiding this comment.
LGTM, thanks. @data-douser Can you add some details in the PR body on how this PR makes the extractor chain to keep going even when the dependencies fail to be installed?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What This PR Contributes
This pull request introduces significant improvements to the CDS extractor diagnostics system, with a focus on ensuring that all diagnostic file paths are reported as relative to the source root. This change enhances compatibility with CodeQL requirements and improves the clarity of diagnostic messages. The update affects both the implementation in source files and the corresponding test cases, and adds new utility logic for path conversion.
Diagnostic Path Handling Improvements
src/diagnostics.tsnow accept an optionalsourceRootparameter and use the newconvertToRelativePathutility to ensure that diagnostic file paths are relative to the source root, defaulting to.if the file is outside the source root. [1] [2] [3] [4]cds-extractor.ts,src/codeql.ts, andsrc/cds/compiler/retry.tshave been updated to pass the appropriatesourceRootargument, ensuring consistent diagnostic reporting. [1] [2] [3] [4] [5] [6] [7] [8] [9]Diagnostic Utility Enhancements
convertToRelativePathinsrc/diagnostics.tsto robustly resolve file paths relative to the source root, with fallback logic for files outside the root.addCompilationDiagnostic,addDependencyGraphDiagnostic,addDependencyInstallationDiagnostic,addEnvironmentSetupDiagnostic,addJavaScriptExtractorDiagnostic,addNoCdsProjectsDiagnostic) now support relative path conversion via the new utility. [1] [2] [3] [4] [5] [6] [7] [8]Test Suite Updates
test/src/cds/compiler/retry.test.ts,test/src/codeql.test.ts, andtest/src/diagnostics.test.tshave been updated to include the newsourceRootparameter in diagnostic function calls, ensuring correct test coverage of the new logic. [1] [2] [3] [4]Documentation and Instructions
.github/instructions/extractors_cds_tools_ts.instructions.mdto clearly document requirements, preferences, and constraints for CDS extractor TypeScript source and test files, including the new mandate for relative diagnostic paths.References:
[1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] [21] [22] [23] [24] [25] [26]
Future Works
None