MistDemo: --database flag + demo-errors command (closes #259, #269)#282
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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 |
Code ReviewOverall: Clean, well-structured PR. The deduplication of database parsing into Issues1. 409 scenario: single
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## v1.0.0-beta.1 #282 +/- ##
==================================================
+ Coverage 25.66% 53.10% +27.44%
==================================================
Files 95 245 +150
Lines 8240 18193 +9953
==================================================
+ Hits 2115 9662 +7547
- Misses 6125 8531 +2406
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Code Review PR 282: --database flag + demo-errors command Overview What is good
Issues DemoErrorsRunner.runUnauthorized hardcodes .private. Missing .shared label in printRunnerHeader. Conflict scenario does not print the stale tag when it is nil. DemoErrorsRunner is internal but its methods are also internal. The runUnauthorized/runNotFound/runConflict methods could be private since they are only called from run(scenario:). Marking them private would narrow the surface area. Minor
Verdict Solid feature addition. The factory consolidation alone is a meaningful cleanup. Address the hardcoded .private in runUnauthorized and the nil-tag edge case in runConflict before the talk; the rest are polish. |
665b2cb to
ff1528f
Compare
Code Review — PR #282: MistDemo
|
ff1528f to
2852f6d
Compare
Adds shared --database flag on MistDemoConfig (default public) so all commands can target any CloudKit database without rebuilding, and introduces a demo-errors command that walks through 401, 404, and 409 typed CloudKitError handling for the "CloudKit as Your Backend" talk. Also adds --bad-credentials on MistDemoConfig for in-context 401 demos. Closes #259, #269. Tracking: #281. Behavior change: commands that previously hardcoded .private now default to .public; pass --database private to keep prior behavior. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2852f6d to
89e949c
Compare
Code Review: PR #282 —
|
| Priority | Issue |
|---|---|
| Critical | Placeholder tokens fail local validation — 401 demo shows n/a, not 401 |
| Major | badCredentials on .public uses WebAuthTokenManager (wrong auth model) |
| Moderate | 409 catch block masks step 1/2 failures with misleading recovery hint |
| Moderate | Stale help text after default switch from .private to .public |
| Moderate | current-user semantic change on .public DB not called out |
| Low | badCredentials path has no unit test coverage |
| Low | Factory docstring doesn't describe badCredentials short-circuit |
The critical fix needed before the talk: use format-valid placeholder tokens (String(repeating: "0", count: 64) for the API token) so the 401 demo actually reaches Apple's servers.
🤖 Generated with Claude Code
- 401: the 19-char "invalid_demo_token" placeholders failed WebAuthTokenManager.validateCredentials() locally, surfacing as CloudKitError.underlyingError with a nil httpStatusCode (the demo printed "status: n/a" instead of "status: 401"). Switch to format-valid tokens (64-char hex API token, 100-char web-auth token) via a shared MistKitClientFactory.makeBadCredentialsTokenManager(), and reject badCredentials + .public early since neither auth manager can fake a server-rejected request on the public DB. - 409: split the single do/catch wrapping create -> update -> stale-update into per-step blocks, and gate the "Recovery: read serverRecord and merge" hint on httpStatusCode == 409 so setup failures don't trigger it. - Help text: drop stale "(private database) by default" in lookup-zones and upload-asset; document --database in create/update/query/fetch-changes/current-user; add a NOTES block to current-user about the auth model per database. - Tests: cover badCredentials on private/shared/public(throws)/ false plus a format-validity check for the shared bad-token helper. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Code Review — PR #282: --database flag + demo-errors commandOverall: Well-scoped pair of features. The factory refactor is clean and the demo-errors scenarios are pedagogically well-designed for the talk. Key items below. Breaking behavior change (intentional, but verify defaults)Commands that previously hardcoded
|
Code Review: PR #282 — MistDemo: --database flag + demo-errors commandOverviewTwo paired changes: (1) replaces per-command hardcoded database values with a shared Strengths
Issues1. Behavior change breaks existing users without a flag Several commands already have this (e.g. 2. No cleanup-on-failure for the 409 demo scenario 3. 4. Hardcoded environment: 'development'This is pre-existing behavior but the new PR makes 5. Minor
SummaryThe |
Code Review — PR #282:
|
Code ReviewOverviewThis PR bundles two well-scoped features for the "CloudKit as Your Backend" talk:
The architecture is solid overall. The key concerns are a potential compile error, one breaking public API change, and a few medium-priority security/test gaps. 🔴 High Priority1. In } catch {
printCloudKitError(error, expectedStatus: 409)
if error.httpStatusCode == 409 {
if let ckError = error as? CloudKitError, ckError.httpStatusCode == 409 {2. The 🟡 Medium Priority3.
4. XSS risk in
5. The JS 6. Missing tests for
🔵 Low Priority7. Dead code in configuration.string(forKey: "scenario", default: "all") ?? "all"The 8. Every future field addition requires updating both the memberwise public func with(database: MistKit.Database) -> MistDemoConfig {
var copy = self
copy.database = database // requires var stored property or a mutable copy approach
return copy
}If the struct fields can be made 9. Test helper defaults
10. The new 11. The struct holds only Summary Table
Overall this is a clean, well-structured PR. The two high-priority items should be verified before merge; the rest can be addressed here or in follow-ups. 🤖 Generated with Claude Code |
Code Review — PR #282: MistDemo: --database flag + demo-errors commandOverviewThis PR moves database selection out of individual command call sites and into ✅ What's well done
|
Summary
Implements parent issue #281, bundling two paired MistDemo changes for the "CloudKit as Your Backend" talk:
--databaseflag onMistDemoConfigso every command can targetpublic/private/sharedwithout rebuilding. Single source of truth; matches theTestIntegrationConfigreference (which is now de-duplicated).demo-errorscommand walks 401 / 404 / 409 scenarios with typedCloudKitErrorhandling for the talk's Act 3, Step 4. Also adds a--bad-credentialsflag onMistDemoConfigfor in-context 401 demos on existing commands.Behavior change
Commands that previously hardcoded
.private(create,update,delete,lookup,modify,current-user,upload-asset,lookup-zones,fetch-changes) now default to.public(matchingTestIntegrationConfig's precedent). Pass--database privateto keep prior behavior. Two intentional exceptions:test-privateis pinned to.private;auth-tokenignores the flag (no DB).What's new
MistKitClientFactory.create(for:)and.create(_:for:)— the new entry points commands use; honor bothdatabaseandbadCredentialstransparently.DemoErrorsCommand—mistdemo demo-errors [--scenario all|401|404|409] [--database <db>].recordChangeTag. Cleans up the demo record on completion.Test plan
🤖 Generated with Claude Code
Perform an AI-assisted review on