Skip to content

Fix TypeError when conda 26.x returns dict from fetch_latest()#1196

Open
gabrielbusta wants to merge 4 commits intoconda:mainfrom
gabrielbusta:fix-conda-constructor-type-error
Open

Fix TypeError when conda 26.x returns dict from fetch_latest()#1196
gabrielbusta wants to merge 4 commits intoconda:mainfrom
gabrielbusta:fix-conda-constructor-type-error

Conversation

@gabrielbusta
Copy link
Copy Markdown

@gabrielbusta gabrielbusta commented Apr 3, 2026

Description

Hi I ran into an issue running an installer build, and I think it is a constructor/conda compatibility issue:

2026-04-03T16:14:40.0074762Z Traceback (most recent call last):
2026-04-03T16:14:40.0116947Z   File "D:\a\_temp\_constructor_workdir\constructor\Scripts\constructor-script.py", line 10, in <module>
2026-04-03T16:14:40.0118364Z     sys.exit(main())
2026-04-03T16:14:40.0119033Z              ~~~~^^
2026-04-03T16:14:40.0121096Z   File "D:\a\_temp\_constructor_workdir\constructor\Lib\site-packages\constructor\main.py", line 610, in main
2026-04-03T16:14:40.0122090Z     main_build(
2026-04-03T16:14:40.0122516Z     ~~~~~~~~~~^
2026-04-03T16:14:40.0122951Z         dir_path,
2026-04-03T16:14:40.0123651Z         ^^^^^^^^^
2026-04-03T16:14:40.0124099Z     ...<7 lines>...
2026-04-03T16:14:40.0124542Z         debug=args.debug,
2026-04-03T16:14:40.0125031Z         ^^^^^^^^^^^^^^^^^
2026-04-03T16:14:40.0125483Z     )
2026-04-03T16:14:40.0125883Z     ^
2026-04-03T16:14:40.0127095Z   File "D:\a\_temp\_constructor_workdir\constructor\Lib\site-packages\constructor\main.py", line 404, in main_build
2026-04-03T16:14:40.0128009Z     create(info, verbose=verbose)
2026-04-03T16:14:40.0128390Z     ~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
2026-04-03T16:14:40.0129094Z   File "D:\a\_temp\_constructor_workdir\constructor\Lib\site-packages\constructor\winexe.py", line 371, in create
2026-04-03T16:14:40.0129611Z     preconda_write_files(info, tmp_dir)
2026-04-03T16:14:40.0129868Z     ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
2026-04-03T16:14:40.0130367Z   File "D:\a\_temp\_constructor_workdir\constructor\Lib\site-packages\constructor\preconda.py", line 192, in write_files
2026-04-03T16:14:40.0130909Z     write_index_cache(info, pkgs_dir, all_dists)
2026-04-03T16:14:40.0131193Z     ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
2026-04-03T16:14:40.0131723Z   File "D:\a\_temp\_constructor_workdir\constructor\Lib\site-packages\constructor\preconda.py", line 81, in write_index_cache
2026-04-03T16:14:40.0133286Z     repodatas = {url: get_repodata(url) for url in _urls if url is not None}
2026-04-03T16:14:40.0133648Z                       ~~~~~~~~~~~~^^^^^
2026-04-03T16:14:40.0134180Z   File "D:\a\_temp\_constructor_workdir\constructor\Lib\site-packages\constructor\conda_interface.py", line 134, in get_repodata
2026-04-03T16:14:40.0134770Z     full_repodata = json.loads(raw_repodata_str)
2026-04-03T16:14:40.0135203Z   File "D:\a\_temp\_constructor_workdir\constructor\Lib\json\__init__.py", line 345, in loads
2026-04-03T16:14:40.0135985Z     raise TypeError(f'the JSON object must be str, bytes or bytearray, '
2026-04-03T16:14:40.0136636Z                     f'not {s.__class__.__name__}')
2026-04-03T16:14:40.0137227Z TypeError: the JSON object must be str, bytes or bytearray, not dict

Checklist - did you ...

  • Add a file to the news directory (using the template) for the next release's release notes?
  • Add / update necessary tests?
  • Add / update outdated documentation?

@conda-bot
Copy link
Copy Markdown
Contributor

We require contributors to sign our Contributor License Agreement and we don't have one on file for @gabrielbusta.

In order for us to review and merge your code, please e-sign the Contributor License Agreement PDF. We then need to manually verify your signature, merge the PR (conda/infrastructure#1308), and ping the bot to refresh the PR.

Copy link
Copy Markdown
Contributor

@marcoesters marcoesters left a comment

Choose a reason for hiding this comment

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

Thank you! This looks good, but we need a news file to this PR as described in the checklist. Please also let me know CLA has been signed and I can get the bot CLA check to re-run.

In conda 26.x, `subdir_data.repo_fetch.fetch_latest()` returns an
already-parsed dict instead of a JSON string. Add a type check to
handle both cases, maintaining backward compatibility with older
conda versions.
@gabrielbusta gabrielbusta force-pushed the fix-conda-constructor-type-error branch from 21205a8 to 7f42508 Compare April 6, 2026 16:33
@gabrielbusta gabrielbusta requested a review from a team as a code owner April 6, 2026 16:33
@conda-bot conda-bot added the cla-signed [bot] added once the contributor has signed the CLA label Apr 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed [bot] added once the contributor has signed the CLA

Projects

Status: 🆕 New

Development

Successfully merging this pull request may close these issues.

3 participants