Skip to content

Avoid getCalendarById on HarmonyOS to fix isPrimary column error#1114

Merged
robertying merged 2 commits into
mainfrom
claude/issue-1112-20260625-2332
Jun 26, 2026
Merged

Avoid getCalendarById on HarmonyOS to fix isPrimary column error#1114
robertying merged 2 commits into
mainfrom
claude/issue-1112-20260625-2332

Conversation

@robertying

Copy link
Copy Markdown
Owner

HarmonyOS 4.2.0 does not expose the isPrimary column directly in the calendar content provider — it's only available as a COALESCE expression. expo-calendar's native getCalendarById queries this column, causing an IllegalArgumentException crash when syncing assignments on Huawei devices.

Replace Calendar.ExpoCalendar.get(calendarId) with Calendar.getCalendars() followed by a find-by-id lookup, which uses a different native code path that does not query isPrimary directly.

Fixes #1112

Generated with Claude Code

HarmonyOS 4.2.0 does not expose the `isPrimary` column directly in the
calendar content provider — it's only available as a COALESCE expression.
expo-calendar's native `getCalendarById` queries this column, causing an
IllegalArgumentException crash when syncing assignments on Huawei devices.

Replace Calendar.ExpoCalendar.get(calendarId) with Calendar.getCalendars()
followed by a find-by-id lookup, which uses a different native code path
that does not query isPrimary directly.

Fixes #1112

Co-authored-by: Rui Ying <robertying@users.noreply.github.com>
@robertying

Copy link
Copy Markdown
Owner Author

@claude can you fix and patch the source instead?

@claude

claude Bot commented Jun 25, 2026

Copy link
Copy Markdown

Claude finished @robertying's task in 9m 38s —— View job


Tasks

  • Gather context and understand the request
  • Locate the native expo-calendar source for patching
  • Create a patch for the HarmonyOS isPrimary column bug
  • Revert the JS-level workaround in src/helpers/event.ts
  • Commit and push changes

I'm unable to create the patch in this run because:

  1. node_modules are not installed — the workflow doesn't run pnpm install, so there are no local expo-calendar source files to diff against.
  2. Network access is blockednpm, curl, gh api, and WebFetch all require explicit permission grants that aren't configured for this action.

patch-package patches require exact line-by-line diffs matched against the installed source; I can't synthesize one without the original file.

What the patch would do

The fix is in node_modules/expo-calendar/android/src/main/java/expo/modules/calendar/CalendarModule.kt (or a helper class). The getCalendarByIdAsync function queries the Android calendar content provider with isPrimary in its column projection, which crashes on HarmonyOS where that column is only available as a COALESCE expression. The getCalendarsAsync function avoids this by not including isPrimary directly in its projection.

The patch would change the getCalendarByIdAsync projection to either:

  • Remove isPrimary (matching what getCalendars does), or
  • Wrap it: "COALESCE(isPrimary, 0) AS isPrimary"

To unblock this

Add a pnpm install step to the workflow before the Claude Code step, or add Bash(npm:*) / Bash(curl:*) to claude_args in .github/workflows/claude.yml:

- name: Install dependencies
  run: pnpm install --ignore-scripts
  
- name: Run Claude Code
  uses: anthropics/claude-code-action@v1
  with:
    claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}

Or alternatively:

claude_args: '--allowed-tools Bash(npm:*) WebFetch'

Once node_modules are available I can run npx patch-package expo-calendar after editing the file to auto-generate the correct patch.

Instead of working around the bug in JS, patch the native source.

expo-calendar's next-module `CalendarRepository.findById` queries the
calendar *item* URI (ContentUris.withAppendedId) with `isPrimary` in its
projection. On HarmonyOS 4.2.0 the item URI does not expose the computed
`isPrimary` column, causing an IllegalArgumentException. The collection
URI used by `findAll`/`getCalendars` does expose it, which is why that
path works.

Patch `findById` to query the collection URI with an `_ID = ?` filter
(the same path that works for `getCalendars`), and revert the JS-level
workaround in src/helpers/event.ts so it uses `ExpoCalendar.get` again.

Fixes #1112

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@robertying
robertying merged commit 0ee4bcd into main Jun 26, 2026
1 check passed
@robertying
robertying deleted the claude/issue-1112-20260625-2332 branch June 26, 2026 02:42
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.

[Bug] 更新后作业同步失败并伴有报错

1 participant