Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capture and report CDS compilation errors #162

Merged
merged 2 commits into from
Dec 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions extractors/cds/tools/index-files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,13 @@ echo "Processing CDS files to JSON"
# the same name
while IFS= read -r cds_file; do
echo "Processing CDS file $cds_file to:"
$cds_command compile "$cds_file" \
-2 json \
-o "$cds_file.json" \
--locations
if ! $cds_command compile "$cds_file" -2 json -o "$cds_file.json" --locations 2> "$cds_file.err"; then
stderr_truncated=`grep "^\[ERROR\]" "$cds_file.err" | tail -n 4`
error_message=$'Could not compile the file '"$cds_file"$'.\nReported error(s):\n```\n'"$stderr_truncated"$'\n```'
echo "$error_message"
# Log an error diagnostic which appears on the status page
"$CODEQL_DIST/codeql" database add-diagnostic --extractor-name cds --ready-for-status-page --source-id cds/compilation-failure --source-name "Failure to compile one or more SAP CAP CDS files" --severity error --markdown-message "$error_message" --file-path "$cds_file" "$CODEQL_EXTRACTOR_CDS_WIP_DATABASE"
fi
done < "$response_file"

# Check if the JS extractor variables are set, and set them if not
Expand Down
Loading