Repository navigation
Conversation
📝 WalkthroughWalkthroughThis PR centralizes case-insensitive built-in integration detection by adding export isBuiltinIntegration (lowercases input and checks BUILTIN_INTEGRATIONS). collectRequiredIntegrationIds and checkMissingIntegrations are updated to use the helper; checkMissingIntegrations also type-guards sql_integration_id to strings. New tests verify mixed-case built-ins are recognized, external IDs are preserved, and non-string metadata does not crash analysis. Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 5 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/cli/src/utils/analysis.ts`:
- Around line 519-523: The metadata.sql_integration_id value is not being
type-checked so a non-string truthy value can crash inside isBuiltinIntegration
(which calls .toLowerCase()); update the guard around integrationId (the
variable assigned from block.metadata) to ensure it's a string before calling
isBuiltinIntegration—e.g., check typeof integrationId === 'string' (or coerce
safely) and continue when it's missing or not a string or when
isBuiltinIntegration(integrationId) returns true; adjust the condition that
currently reads using integrationId and isBuiltinIntegration to short-circuit
non-string values.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 513ddd31-54d4-4f5d-b0e8-cdfbaa855c16
📒 Files selected for processing (6)
packages/cli/src/constants.test.tspackages/cli/src/constants.tspackages/cli/src/integrations/collect-integrations.test.tspackages/cli/src/integrations/collect-integrations.tspackages/cli/src/utils/analysis.test.tspackages/cli/src/utils/analysis.ts
Card 234rnd (done) — fix shipped as draft PR deepnote#399 (Closes deepnote#325). Roadmap m1/s4/.../case-insensitive-id-filtering marked done; all five features of story m1/s4 now complete. Out-of-scope external-ID case-insensitivity captured as backlog card ca0ios.
A truthy non-string sql_integration_id in file metadata reached isBuiltinIntegration() and crashed on .toLowerCase(). Guard the type at the call site (mirroring the zod parse in collect-integrations.ts) so malformed metadata is ignored rather than throwing. Adds a regression test.
Self-review (high-effort pass) — findings & resolutionsRan a multi-angle review of this PR. Summary: the core fix is sound; one real regression was found (by CodeRabbit, now fixed) plus two low-severity notes. 1. 🟠 Crash on non-string
|
|
@coderabbitai resolve |
CodeRabbit found a non-string sql_integration_id crash regression; fixed in code commit 0d7c471 on the PR branch. Two low-sev self-review notes resolved (external-casing deferred to ca0ios; fixture dup kept).
✅ Action performedComments resolved and changes approved. |
|
Closing this in favor of a single consolidated PR that ships the complete fix (built-in and external case-insensitive integration-ID handling) in one coherent change. |
Adapt the superpowers `contributing` skill (cp'd from ../superpowers) into a deepnote-specific upstream-contribution method, grounded in a measured baseline of deepnote/deepnote — not a relabel of obra-specific data. Key retargets: - Method kept (never-post-directly gate, socialize-first, clean code-only branch off upstream/main, groundedness, credibility ledger); obra threat-catalogue voice and empirical case-studies dropped as miscalibrated for deepnote. - Baseline (CREDIBILITY.md) rebuilt from real gh queries: ~325 merges, ~2% external-merge rate, median external merge +7 lines, features close as "already in-house / please fork", CodeRabbit reviews every PR, no AI/disclosure policy, sign-commits bar. Real footprint logged (deepnote#399/deepnote#400 closed, deepnote#401/deepnote#402 open, jamesbhobbs engaged deepnote#401). - Scripts rewritten + shellcheck-clean + selftest 30/30: fork-setup verifies deepnote's tracked-board model (not superpowers' invisible-artifact guardrail); preflight targets `main`, disclosure optional; check-upstream flags maintainers from MAINTAINERS.txt; selftest recalibrated. - Reconciliation: skill owns METHOD, .claude/CLAUDE.md owns deepnote CONVENTIONS (branch names, Discussion #5, showcase spec); each cross-references the other.
Note
Maintainers — CI needs your approval to run. As a first-time contributor from a fork, the GitHub Actions workflows on this PR are held in the
action_requiredstate and won't run until a maintainer clicks “Approve and run workflows.” Could someone kick them off when you have a moment? 🙏In the meantime I reproduced the CI jobs locally against this branch:
pnpm lintAndFormat→ ✅ pass (Biome + Prettier; only the pre-existingruntime-coreconsole warning, untouched here)pnpm spell-check→ ✅ no issues on the changed filespnpm --filter @deepnote/cli test→ ✅ 25/25 on the touched suites (constants,collect-integrations,analysis), incl. the regression test for CodeRabbit's catchtsc --noEmit(cli) → ✅ clean(The unrelated pre-existing
diff.test.tscwd/fixture failure is untouched by this PR.)Closes #325
The constraint
The CLI decides whether a SQL block's
sql_integration_idrefers to a built-in engine (no external credentials, never linted as "missing") or an external integration (collected as required, checked bylint). That decision is a case-sensitive set membership test.BUILTIN_INTEGRATIONSholds canonical lowercase IDs (deepnote-dataframe-sql,pandas-dataframe), and two call sites query it with rawSet.has(integrationId):packages/cli/src/integrations/collect-integrations.ts:17packages/cli/src/utils/analysis.ts:522A notebook is just data, and
sql_integration_idis whatever the author typed. A built-in referenced asPandas-DataFrameorDeepnote-DataFrame-SQLdoes not match the lowercase set, so it silently falls through the built-in filter and is treated as external. There's no crash — the block is added to the required-integration set (triggering credential fetches it doesn't need), anddeepnote lintreports a bogus missing-integration error:The inconsistency is local to this filter: the codebase already normalizes integration IDs to lowercase when matching elsewhere (
integrations/fetch-and-merge-integrations.ts). The built-in check predates that convention and was never reconciled with it.What's now possible
A built-in integration is recognized as built-in regardless of how it was capitalized.
isBuiltinIntegration('Pandas-DataFrame'),'PANDAS-DATAFRAME', and'pandas-dataframe'all returntrue; a genuine external ID returnsfalse. A built-in referenced in non-canonical casing is never collected as a required external integration and never flagged as missing bylint. Authors stop having to remember the exact canonical casing to avoid a false lint failure.Why this design
The minimal patch would be to drop
.toLowerCase()at eachhas()call site. We rejected that because it duplicates the normalization rule across two files, and a third future call site would silently reintroduce the bug — the same drift that caused this issue in the first place. Instead the casing rule lives in one exported predicate,isBuiltinIntegration(), and both call sites route through it, so the built-in check has a single source of truth that call sites cannot diverge from. This mirrors the lowercase-normalization convention already used infetch-and-merge-integrations.ts, keeping the package internally consistent. The price: one extra function-call indirection over a bareSet.has, and one more symbol exported fromconstants.ts— cheap relative to a correctness check that two (and growing) call sites depend on.What it looks like
Both call sites now read through the predicate instead of touching the set directly:
Note the collection path still adds
integrationId(the original string) to the set — only the membership test is normalized, so genuine external IDs keep their original casing in the result.How we know it works
Developed test-first: the failing test was written and confirmed red before the predicate existed, then went green with the fix. Coverage lands at all three layers:
constants.test.ts(new)isBuiltinIntegrationreturnstruefor canonical, all-upper, and mixed casing of both built-ins;falsefor a genuine external ID and for an ID that differs from a built-in only by suffixcollect-integrations.test.ts(new)analysis.test.ts(additions)The capstone case is exercised in
collect-integrations.test.ts— a file with one mixed-case built-in block (Deepnote-DataFrame-SQL) and one external block (my-warehouse):The built-in is filtered out and exactly
my-warehouseis collected / flagged.Validation
pnpm --filter @deepnote/cli test run— the integration-ID files all pass:constants.test.ts(4),collect-integrations.test.ts(3),analysis.test.ts(17). The wider cli suite has one pre-existing, unrelated failure insrc/commands/diff.test.ts(a working-directory / fixture-path issue that callsprocess.exit(2)independent of this change) — it fails identically on the unmodified base and is not touched by this PR.Risks and limitations
Behavior-preserving for canonical-cased IDs: any ID already matching the lowercase set continues to match. The change only widens what counts as built-in (to other casings of the same IDs), so the only directional shift is that a block which previously linted as a missing external integration purely because of casing now correctly does not — the intended fix.
Rollback
Pure, side-effect-free predicate change, no migration and no runtime state. Revert the commit to restore prior behavior.
Scope
No
.gitban/or.claude/files are included — this branch is the six-file code change underpackages/cli/only.Summary by CodeRabbit
Release Notes
Bug Fixes
Tests