Skip to content

Commit 26aac24

Browse files
vaindclaude
andcommitted
fix: Handle CHANGELOG.md not in PR diff for inline suggestions
GitHub PR review comments API can only target files that are part of the PR diff. When CHANGELOG.md is not modified in the PR, we cannot create inline suggestions and must fall back to markdown instructions. Changes: - Check if changelogFile is in danger.git modified/created/deleted files - Fall back to markdown instructions when file not in diff - Add warning log explaining why inline suggestions cannot be used This fixes the CI error: "could not be resolved" for pull_request_review_thread.path 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent c4e607f commit 26aac24

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

danger/dangerfile.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,21 @@ async function reportMissingChangelog(changelogFile) {
103103
const flavorConfig = getFlavorConfig(prFlavor);
104104
const sectionName = flavorConfig.changelog || "Features";
105105

106+
// Check if changelog file is part of the PR diff
107+
// GitHub API can only create review comments on files that are modified in the PR
108+
const allChangedFiles = danger.git.created_files
109+
.concat(danger.git.modified_files)
110+
.concat(danger.git.deleted_files);
111+
112+
const isChangelogInDiff = allChangedFiles.includes(changelogFile);
113+
114+
if (!isChangelogInDiff) {
115+
// Cannot create inline suggestions on files not in the diff
116+
console.log(`::warning::Cannot create inline suggestion: ${changelogFile} is not modified in this PR`);
117+
showMarkdownInstructions(changelogFile, sectionName);
118+
return;
119+
}
120+
106121
try {
107122
// Get changelog content
108123
const changelogContent = await danger.github.utils.fileContents(changelogFile);

0 commit comments

Comments
 (0)