feat(react-native): skip patch native files when expo CNG#1211
feat(react-native): skip patch native files when expo CNG#1211uragirii wants to merge 3 commits intogetsentry:masterfrom
Conversation
| export const isExpoCNG = async (): Promise<boolean> => { | ||
| const nativeFoldersExist = fs.existsSync('ios') || fs.existsSync('android'); | ||
|
|
||
| if (!nativeFoldersExist) { | ||
| // Definitely CNG and using prebuild steps | ||
| return true; | ||
| } | ||
|
|
||
| return await areNativeFoldersInGitignore(); | ||
| }; |
There was a problem hiding this comment.
Bug: The areNativeFoldersInGitignore function incorrectly requires both 'ios' and 'android' folders in .gitignore, causing single-platform Expo CNG projects to be misidentified.
Severity: HIGH
Suggested Fix
Modify areNativeFoldersInGitignore to only check for the presence of existing native folders in .gitignore. The function should first determine which native folders (ios or android) exist on the filesystem and then verify that only those existing folders are included in the gitignore file.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: src/react-native/expo.ts#L201-L210
Potential issue: The `isExpoCNG` function incorrectly identifies single-platform Expo
CNG projects (e.g., with only an 'ios' folder) as non-CNG. This occurs because its
helper function, `areNativeFoldersInGitignore`, uses `.every()` to require that both
'ios' and 'android' folders are present in the `.gitignore` file. For a valid
single-platform project, this check will always fail because one of the native folders
does not exist and is therefore not in `.gitignore`. This causes `isExpoCNG` to return
`false`, leading to incorrect attempts to patch native files that should be treated as
immutable build artifacts.
Did we get this right? 👍 / 👎 to inform future reviews.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
|
|
||
| return NATIVE_FOLDERS.every((folder) => { | ||
| return lines.some((line) => { | ||
| const lineWithoutComment = line.split('#')[0].trim(); |
There was a problem hiding this comment.
Gitignore parser incorrectly strips mid-line hash characters
Low Severity
The line.split('#')[0] approach treats # anywhere on a line as a comment delimiter. Per the gitignore spec, # only starts a comment when it's the first non-whitespace character on the line — mid-line # is a literal part of the pattern. A gitignore entry like ios # native would be incorrectly parsed as matching ios, even though git treats the entire string (including the #) as a literal pattern. This could cause a false positive for isExpoCNG, leading to native file patching being skipped when it shouldn't be. A simpler approach — checking if the trimmed line starts with # to identify comment lines — would match gitignore semantics correctly.


Description
AI Disclosure