Conversation
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
There was a problem hiding this comment.
Bug: Unconsented Data Push and Error Suppression
The pushRepos method hardcodes remote repository URLs, pushing user data to specific external repositories without consent. It uses git push --force, risking remote history overwrite and data loss. Furthermore, all git command errors are silently ignored, hiding failures. This includes git remote add origin failing on subsequent runs if the remote exists, potentially causing git push to fail or push to an unintended remote.
packages/cli/src/notion/index.ts#L733-L743
notion-node/packages/cli/src/notion/index.ts
Lines 733 to 743 in 4c84671
Bug: Git Command Failures Silently Ignored
The run helper function within pushRepos() silently ignores all git command failures via an empty catch block. This prevents users from being notified of critical issues (e.g., authentication, network, or repository access problems), leading to a false sense of success, hindering debugging, and potentially leaving repositories in inconsistent states.
packages/cli/src/notion/index.ts#L720-L744
notion-node/packages/cli/src/notion/index.ts
Lines 720 to 744 in 4c84671
BugBot free trial expires on June 13, 2025
You have used $0.00 of your $0.00 spend limit so far. Manage your spend limit in the Cursor dashboard.
Was this report helpful? Give feedback by reacting with 👍 or 👎
There was a problem hiding this comment.
Pull Request Overview
This PR adds a --push flag to the export CLI, enabling automatic Git pushes of exported Notion data to two remote repositories.
- Introduces a
pushproperty and command‐line flag - Implements a
pushRepos()method that initializes Git repos and force‐pushes to designated remotes - Hooks the new flag into the export command to run
pushRepos()when requested
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/cli/src/notion/index.ts | Imported execSync, added push flag/property, implemented git push logic in pushRepos() |
| packages/cli/src/notion/export.ts | Added --push option to CLI and wired it to invoke pushRepos() |
Comments suppressed due to low confidence (1)
packages/cli/src/notion/index.ts:721
- The new
pushRepos()logic isn’t covered by tests—consider adding unit or integration tests to verify the git commands execute as expected.
pushRepos() {
packages/cli/src/notion/index.ts
Outdated
| const run = (cmd: string, cwd: string) => { | ||
| try { | ||
| execSync(cmd, { cwd, stdio: 'ignore' }) | ||
| } catch {} |
There was a problem hiding this comment.
Silently swallowing errors makes debugging push failures difficult; consider logging caught exceptions or at least printing a warning.
| } catch {} | |
| } catch (error) { | |
| console.error(`Failed to execute command "${cmd}" in directory "${cwd}":`, error.message); | |
| } |
Fixes the no-empty ESLint error by adding an explanatory comment. Also reverts unrelated test change from results.total to results.results.length. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Required for Search API tests that need authentication. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Fix ESLint 9.x compatibility by adding ESLINT_USE_FLAT_CONFIG=false Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
📝 WalkthroughWalkthroughThe changes introduce a new Changes
Sequence DiagramsequenceDiagram
participant User
participant CLI as NotionExportCommand
participant Exporter as NotionExporter
participant Git as Git Operations
User->>CLI: Execute with --push flag
CLI->>CLI: Capture push option
CLI->>Exporter: new NotionExporter({push: true, ...})
Exporter->>Exporter: Store push property
CLI->>Exporter: execute()
Exporter->>Exporter: Perform export logic
Note over Exporter: Export completes
CLI->>Exporter: Check this.push condition
alt push flag enabled
CLI->>Exporter: pushRepos()
Exporter->>Git: Execute git init/add/commit/branch/remote/push<br/>(texonom-raw)
Git-->>Exporter: Complete (errors ignored)
Exporter->>Git: Execute git init/add/commit/branch/remote/push<br/>(texonom-md)
Git-->>Exporter: Complete (errors ignored)
Exporter-->>CLI: Return
end
CLI-->>User: Export + push complete
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/cli/src/notion/export.ts (1)
73-84:⚠️ Potential issue | 🟠 MajorPush happens before treemap/stats generation.
With
--pushplus--treemap/--stats, the repositories are pushed before those artifacts are created. Move the push to the end so the generated files are included.✅ Suggested reorder
- await exporter.execute() - if (this.push) await exporter.pushRepos() + await exporter.execute() if (this.treemap || this.stats) if (!exporter.pageTree) await exporter.loadRaw() @@ if (this.stats && tree) { const stats = computeStats(tree) await writeStats(`${this.folder}/stats.json`, stats) } + if (this.push) await exporter.pushRepos()
🤖 Fix all issues with AI agents
In `@packages/cli/src/notion/index.ts`:
- Around line 721-745: The pushRepos method currently swallows all execSync
errors in the local run helper and uses --force when pushing, so update
pushRepos/run to surface real failures and avoid blind force-pushes: change the
run helper (used by pushRepos) to remove the broad empty catch (or rethrow after
handling), execute execSync with stdio: 'inherit' so command errors are visible,
only catch the specific "remote already exists" error when running git remote
add (or check for existing remote before adding), and replace git push --force
with git push --force-with-lease for both this.folder and this.md pushes to
reduce risk of overwriting remote history.
🧹 Nitpick comments (1)
package.json (1)
20-20: Make the lint script cross‑platform (if Windows support matters).
ESLINT_USE_FLAT_CONFIG=falseas a prefix won’t work on Windows shells. If Windows support is required, usecross-env.♻️ Proposed update
- "lint": "ESLINT_USE_FLAT_CONFIG=false eslint \"**/*.{ts,tsx}\" --fix --ignore-path .gitignore --cache", + "lint": "cross-env ESLINT_USE_FLAT_CONFIG=false eslint \"**/*.{ts,tsx}\" --fix --ignore-path .gitignore --cache","devDependencies": { + "cross-env": "^7.0.3",
| pushRepos() { | ||
| const run = (cmd: string, cwd: string) => { | ||
| try { | ||
| execSync(cmd, { cwd, stdio: 'ignore' }) | ||
| } catch { | ||
| // Ignore errors - some commands may fail (e.g., remote already exists) | ||
| } | ||
| } | ||
| const message = new Date().toString() | ||
|
|
||
| // push raw | ||
| run('git init', this.folder) | ||
| run('git add .', this.folder) | ||
| run(`git commit -m "${message}"`, this.folder) | ||
| run('git branch -M main', this.folder) | ||
| run('git remote add origin https://github.com/texonom/texonom-raw.git', this.folder) | ||
| run('git push -u origin main --force', this.folder) | ||
|
|
||
| // push md | ||
| run('git init', this.md) | ||
| run('git add .', this.md) | ||
| run(`git commit -m "${message}"`, this.md) | ||
| run('git branch -M main', this.md) | ||
| run('git remote add origin https://github.com/texonom/texonom-md.git', this.md) | ||
| run('git push -u origin main --force', this.md) |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
# Check if the file exists
fd "index.ts" packages/cli/src/notion/
# Get line count to verify the file size
wc -l packages/cli/src/notion/index.tsRepository: texonom/notion-node
Length of output: 132
🏁 Script executed:
# Read the specific lines mentioned in the review (721-745)
sed -n '721,745p' packages/cli/src/notion/index.tsRepository: texonom/notion-node
Length of output: 958
🏁 Script executed:
# Get broader context around the pushRepos function
sed -n '710,760p' packages/cli/src/notion/index.tsRepository: texonom/notion-node
Length of output: 2190
🏁 Script executed:
# Search for where pushRepos is called
rg "pushRepos" packages/cli/src/notion/index.tsRepository: texonom/notion-node
Length of output: 78
🏁 Script executed:
# Get more context - find the class definition
sed -n '650,730p' packages/cli/src/notion/index.ts | head -100Repository: texonom/notion-node
Length of output: 3421
🏁 Script executed:
# Check imports at the top of the file
head -50 packages/cli/src/notion/index.tsRepository: texonom/notion-node
Length of output: 1455
🏁 Script executed:
# Search for pushRepos usage in the entire codebase
rg "pushRepos" --type tsRepository: texonom/notion-node
Length of output: 191
Avoid silent failures and hard force-pushes in pushRepos.
Swallowing all exec errors makes failed pushes look successful, and --force can overwrite remote history. The current catch block suppresses all errors, not just the "remote already exists" case mentioned in the comment. Prefer surfacing failures via stdio: 'inherit' and using --force-with-lease to reduce risk of silent data loss.
🔧 Safer push flow
- const run = (cmd: string, cwd: string) => {
+ const run = (cmd: string, cwd: string, allowFailure = false) => {
try {
- execSync(cmd, { cwd, stdio: 'ignore' })
- } catch {
- // Ignore errors - some commands may fail (e.g., remote already exists)
+ execSync(cmd, { cwd, stdio: 'inherit' })
+ } catch (err) {
+ if (allowFailure) {
+ console.warn(`[push] ${cmd} failed in ${cwd}`, err)
+ return
+ }
+ throw err
}
}
@@
- run('git remote add origin https://github.com/texonom/texonom-raw.git', this.folder)
- run('git push -u origin main --force', this.folder)
+ run('git remote add origin https://github.com/texonom/texonom-raw.git', this.folder, true)
+ run('git push -u origin main --force-with-lease', this.folder)
@@
- run('git remote add origin https://github.com/texonom/texonom-md.git', this.md)
- run('git push -u origin main --force', this.md)
+ run('git remote add origin https://github.com/texonom/texonom-md.git', this.md, true)
+ run('git push -u origin main --force-with-lease', this.md)🤖 Prompt for AI Agents
In `@packages/cli/src/notion/index.ts` around lines 721 - 745, The pushRepos
method currently swallows all execSync errors in the local run helper and uses
--force when pushing, so update pushRepos/run to surface real failures and avoid
blind force-pushes: change the run helper (used by pushRepos) to remove the
broad empty catch (or rethrow after handling), execute execSync with stdio:
'inherit' so command errors are visible, only catch the specific "remote already
exists" error when running git remote add (or check for existing remote before
adding), and replace git push --force with git push --force-with-lease for both
this.folder and this.md pushes to reduce risk of overwriting remote history.
Summary
--pushflag to export commandtexonom-rawandtexonom-mdTesting
pnpm test(fails: vitest not found)pnpm lint(fails: eslint command issue)https://chatgpt.com/codex/tasks/task_e_6842d06cc8908327aba1258d471728c9
Summary by CodeRabbit
New Features
--pushflag to the Notion export command, enabling automatic repository pushes immediately after export completion. Streamlines the export-and-publish workflow by combining both operations in a single command.Chores