Skip to content

fix(cli): report the default channel when native config has none - #1240

Merged
gronxb merged 1 commit into
gronxb:mainfrom
giaBaoJS:fix/channel-command-default-value
Sep 1, 2026
Merged

fix(cli): report the default channel when native config has none#1240
gronxb merged 1 commit into
gronxb:mainfrom
giaBaoJS:fix/channel-command-default-value

Conversation

@giaBaoJS

@giaBaoJS giaBaoJS commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

hot-updater channel reports an empty channel on any project that has never had
a channel written into its native files, even though the app is running on
production.

Cause

getChannel builds its result by layering the parser output over a default:

return merge(
  { value: DEFAULT_CHANNEL },
  await androidParser.get("hot_updater_channel"),
);

es-toolkit merge only leaves the target value in place when the source value is
undefined. A null source value is copied over:

merge({ value: "production" }, { value: null,      paths: [] }) // { value: null }
merge({ value: "production" }, { value: undefined, paths: [] }) // { value: "production" }

AndroidConfigParser.get and IosConfigParser.get return { value: null } when
the key is absent, so the production default is always discarded in exactly the
case it exists for. Both platforms are affected
(packages/hot-updater/src/utils/setChannel.ts).

Effect

init does not write a channel, so this is the state of a project until someone
runs hot-updater channel set. handleChannel passes the value to
ui.channel, which renders an empty value as -:

Channels
    Android:  -
    Path:     android/app/src/main/AndroidManifest.xml
    iOS:      -
    Path:     ios/HotUpdaterExample/Info.plist

That is misleading rather than merely blank: with no channel in the native
config, HotUpdaterImpl falls back to DEFAULT_CHANNEL = "production" on both
Android and iOS, so the app really is on production. After the fix the command
prints production for both platforms.

Change

Fall back with ?? instead of merge, so only a genuinely absent value is
replaced. Added setChannel.spec.ts covering both platforms plus the
already-configured case; the two fallback tests fail on main with
value: null.

pnpm lint, pnpm test:type and pnpm test all pass (169 files, 2162 tests).

`getChannel` layered the parser result over `{ value: "production" }` with
es-toolkit `merge`, but `merge` only skips `undefined` source values. When a
project has no channel in AndroidManifest.xml or Info.plist the parser returns
`value: null`, which overwrote the default, so `hot-updater channel` printed an
empty channel while the app was actually running on `production` (the native
`DEFAULT_CHANNEL`).

Fall back with `??` so an absent channel reports the same value the native
runtime uses.
@vercel

vercel Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

@giaBaoJS is attempting to deploy a commit to the hot-updater Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot

changeset-bot Bot commented Sep 1, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 733cc6c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 25 packages
Name Type
hot-updater Patch
@hot-updater/android-helper Patch
@hot-updater/apple-helper Patch
@hot-updater/bsdiff Patch
@hot-updater/cli-tools Patch
@hot-updater/console Patch
@hot-updater/core Patch
@hot-updater/react-native Patch
@hot-updater/server Patch
@hot-updater/test-utils Patch
@hot-updater/aws Patch
@hot-updater/bare Patch
@hot-updater/bugsnag-plugin Patch
@hot-updater/cloudflare Patch
@hot-updater/datadog-plugin Patch
@hot-updater/expo Patch
@hot-updater/firebase Patch
@hot-updater/js Patch
@hot-updater/mock Patch
@hot-updater/plugin-core Patch
@hot-updater/postgres Patch
@hot-updater/rock Patch
@hot-updater/sentry-plugin Patch
@hot-updater/standalone Patch
@hot-updater/supabase Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Sep 1, 2026

Copy link
Copy Markdown

Open in StackBlitz

@hot-updater/android-helper

npm i https://pkg.pr.new/@hot-updater/android-helper@1240

@hot-updater/apple-helper

npm i https://pkg.pr.new/@hot-updater/apple-helper@1240

@hot-updater/bsdiff

npm i https://pkg.pr.new/@hot-updater/bsdiff@1240

@hot-updater/cli-tools

npm i https://pkg.pr.new/@hot-updater/cli-tools@1240

@hot-updater/console

npm i https://pkg.pr.new/@hot-updater/console@1240

@hot-updater/core

npm i https://pkg.pr.new/@hot-updater/core@1240

hot-updater

npm i https://pkg.pr.new/hot-updater@1240

@hot-updater/react-native

npm i https://pkg.pr.new/@hot-updater/react-native@1240

@hot-updater/server

npm i https://pkg.pr.new/@hot-updater/server@1240

@hot-updater/aws

npm i https://pkg.pr.new/@hot-updater/aws@1240

@hot-updater/bare

npm i https://pkg.pr.new/@hot-updater/bare@1240

@hot-updater/bugsnag-plugin

npm i https://pkg.pr.new/@hot-updater/bugsnag-plugin@1240

@hot-updater/cloudflare

npm i https://pkg.pr.new/@hot-updater/cloudflare@1240

@hot-updater/datadog-plugin

npm i https://pkg.pr.new/@hot-updater/datadog-plugin@1240

@hot-updater/expo

npm i https://pkg.pr.new/@hot-updater/expo@1240

@hot-updater/firebase

npm i https://pkg.pr.new/@hot-updater/firebase@1240

@hot-updater/js

npm i https://pkg.pr.new/@hot-updater/js@1240

@hot-updater/plugin-core

npm i https://pkg.pr.new/@hot-updater/plugin-core@1240

@hot-updater/postgres

npm i https://pkg.pr.new/@hot-updater/postgres@1240

@hot-updater/rock

npm i https://pkg.pr.new/@hot-updater/rock@1240

@hot-updater/sentry-plugin

npm i https://pkg.pr.new/@hot-updater/sentry-plugin@1240

@hot-updater/standalone

npm i https://pkg.pr.new/@hot-updater/standalone@1240

@hot-updater/supabase

npm i https://pkg.pr.new/@hot-updater/supabase@1240

commit: 733cc6c

@vercel

vercel Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
hot-updater-docs Ready Ready Preview Sep 1, 2026 3:32pm UTC

Request Review

@gronxb

gronxb commented Sep 1, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-01T15:34:11.568452Z 733cc6c Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 733cc6c27b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@gronxb gronxb left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution !

@gronxb
gronxb merged commit 67703ab into gronxb:main Sep 1, 2026
8 checks passed
gronxb added a commit that referenced this pull request Sep 1, 2026
Backport #1240 to next so the channel command reports the same production fallback used by the native runtime.

Co-authored-by: Bao Nguyen <waycaosi1994@gmail.com>
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.

2 participants