Skip to content

Handle empty file paths in cucumber pull#71

Open
PierrickTassery wants to merge 1 commit into
testomatio:masterfrom
PierrickTassery:fix-pull-invalid-file-paths
Open

Handle empty file paths in cucumber pull#71
PierrickTassery wants to merge 1 commit into
testomatio:masterfrom
PierrickTassery:fix-pull-invalid-file-paths

Conversation

@PierrickTassery

@PierrickTassery PierrickTassery commented Jun 4, 2026

Copy link
Copy Markdown

Summary

This keeps the pull workflow from crashing when the API returns an empty file path in data.files.

When the file path is empty, the CLI now generates a fallback filename from the Gherkin Feature: title and writes the file there instead of trying to write the target directory itself.

Refs #70.

Why

check-cucumber pull currently assumes every key in data.files is a writable filename. If the API returns an empty key:

files: {
  "": "Feature: Missing Source Path\n..."
}

then path.join(targetDir, "") resolves to the target directory and fs.writeFileSync fails with:

EISDIR: illegal operation on a directory, open '.'

Changes

  • Add a minimal fallback filename generator for empty file paths.
  • Use the feature title as the fallback filename base.
  • Add a regression test for an empty file path response.

This PR intentionally does not try to solve duplicate source-path collisions; that requires an API-side change because missing feature contents are not present in data.files.

Testing

npm test

Result:

97 passing

@PierrickTassery PierrickTassery force-pushed the fix-pull-invalid-file-paths branch from 86b4d3b to d921b39 Compare June 4, 2026 19:36
@PierrickTassery PierrickTassery changed the title Handle invalid file paths in cucumber pull Handle empty file paths in cucumber pull Jun 4, 2026
@PierrickTassery PierrickTassery force-pushed the fix-pull-invalid-file-paths branch from d921b39 to 9dea4d4 Compare June 4, 2026 19:39
Comment thread pull.js
* @param {Set<string>} usedFileNames - File names already reserved for this pull
* @returns {string} Safe fallback file name
*/
fallbackFileName(content, usedFileNames) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DenysKuchma please check if we can come up wiht better implementaton
regexes look fragile, we need to think about it

@DavertMik

Copy link
Copy Markdown
Contributor

Thanks I will ask our developer to review and merge or provide alternative solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants