Skip to content

fix(core): handle macro data as string in built artifacts - #8828

Closed
junmediatek wants to merge 1 commit into
anomalyco:devfrom
junmediatek:fix/models-macro-string-handling
Closed

junmediatek wants to merge 1 commit into
anomalyco:devfrom
junmediatek:fix/models-macro-string-handling

Conversation

@junmediatek

@junmediatek junmediatek commented Jan 16, 2026 •

Copy link
Copy Markdown
Contributor

Adds check for string type to handle Bun macros inlined at build time.

Changes

Modified the type check to include both function and string types:

// Before
if (typeof data === 'function') {
  const json = await data()
  return JSON.parse(json) as Record<string, Provider>
}

// After  
if (typeof data === 'function' || typeof data === 'string') {
  const json = await data()
  return JSON.parse(json) as Record<string, Provider>
}

Context

When Bun macros are enabled during compilation, the data() function may be executed and inlined as a string literal in the built artifacts. The original code only checked for function type, missing the string case.

@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

@junmediatek

junmediatek commented Jan 16, 2026 •

Copy link
Copy Markdown
Contributor Author

@rekram1-node

Cloud you help to review this PR 74fa97e

@junmediatek

Copy link
Copy Markdown
Contributor Author

Hi @rekram1-node

Could you help to check this PR 74fa97e ?

@junmediatek
junmediatek deleted the fix/models-macro-string-handling branch February 27, 2026 07:34
@junmediatek
junmediatek restored the fix/models-macro-string-handling branch February 27, 2026 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants