Skip to content

fix: follow-up correctness fixes for #230 and #234 - #239

Merged
Yifan Yang (Yif-Yang) merged 1 commit into
microsoft:mainfrom
Yif-Yang:fix/opencode-appdata-and-minimax-base-url
Aug 20, 2026
Merged

fix: follow-up correctness fixes for #230 and #234#239
Yifan Yang (Yif-Yang) merged 1 commit into
microsoft:mainfrom
Yif-Yang:fix/opencode-appdata-and-minimax-base-url

Conversation

@Yif-Yang

Copy link
Copy Markdown
Contributor

Follow-up to #230 and #234, both merged. Each shipped a defect that made the
feature not actually work in the case it was written for.

1. harvest_opencode: the Roaming branch was unreachable (#230)

LOCALAPPDATA or APPDATA resolves to the former in virtually every Windows
session, so the %APPDATA% half of the new branch was dead code and a database
that really lives under Roaming was never found.

Resolve the data root from ordered candidates instead and pick the one that
actually holds opencode.db — the same shape as _devin_transcript_candidates

  • _first_existing in plugins/devin/harvest_devin.py. When no database exists
    yet the Local root stays the reported default, so error messages are unchanged.
    A relative OPENCODE_DB now resolves below the same selected root.

Repro before this patch (both env vars set, db under Roaming) — always picked Local:

sys.platform = "win32"
os.environ["LOCALAPPDATA"] = r"C:\Users\u\AppData\Local"
os.environ["APPDATA"]      = r"C:\Users\u\AppData\Roaming"   # db actually lives here
default_opencode_db()  # -> ...\AppData\Local\opencode\opencode.db

2. minimax_backend: region selection clobbered an explicit base URL (#234)

configure_minimax_chat applied the region default unconditionally and wrote it
into os.environ["MINIMAX_BASE_URL"]. Since trainer.py and eval_only.py pass
cfg.get("minimax_base_url") or None — i.e. None whenever the user did not set
it in YAML — configuring model.minimax_region silently discarded a proxy or
private gateway that the user had set through the environment.

Repro before this patch:

import-time BASE_URL: https://my-corp-proxy.internal/v1
after configure(region="cn_zh"): https://api.minimaxi.com/v1   # proxy gone

Track whether the current base URL was chosen explicitly and only fill in the
region default when it was not. This makes the code match what the docs already
state (docs/guide/configuration.md: "an explicit model.minimax_base_url or
MINIMAX_BASE_URL overrides the region default") — previously the docs were
right and the code was wrong. Region selection still works normally when the
base URL is blank or unset.

Tests

Added regression tests covering exactly the scenarios above:

  • test_default_database_honors_windows_roaming_appdata — APPDATA-only session
  • test_default_database_prefers_the_appdata_root_that_has_the_database — both set, db under Roaming
  • test_default_database_prefers_local_appdata_when_neither_exists — messaging fallback
  • test_relative_opencode_db_resolves_below_the_selected_windows_root
  • test_env_base_url_survives_a_later_region_selection
  • test_explicit_base_url_survives_a_later_region_only_call
  • test_region_still_applies_when_base_url_is_blank

Full suite on this branch: 1114 passed, 10 skipped, 130 subtests passed.

🤖 Generated with Claude Code

Two defects that shipped with the merged PRs:

harvest_opencode: the APPDATA branch added by microsoft#230 was unreachable.
`LOCALAPPDATA or APPDATA` resolves to the former in virtually every
Windows session, so a database that really lives under Roaming was never
found. Probe the candidate roots in order and pick the one that holds
opencode.db, falling back to the Local root for messaging when no
database exists yet; a relative OPENCODE_DB resolves below the same
selected root.

minimax_backend: configure_minimax_chat applied the region default
unconditionally and wrote it into MINIMAX_BASE_URL, so a proxy or
private gateway configured through the environment was silently
discarded as soon as model.minimax_region was set — trainer and
eval_only pass `cfg.get('minimax_base_url') or None`, i.e. None for the
common case. Track whether the base URL was chosen explicitly and only
fill in the region default when it was not, matching what the docs
already state.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@Yif-Yang
Yifan Yang (Yif-Yang) merged commit a11f377 into microsoft:main Aug 20, 2026
1 check passed
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.

1 participant