Skip to content

fix(openai): merge ExtraFields in WithExtraFields instead of overwriting#793

Open
wucm667 wants to merge 2 commits into
cloudwego:mainfrom
wucm667:fix/extra-fields-merge
Open

fix(openai): merge ExtraFields in WithExtraFields instead of overwriting#793
wucm667 wants to merge 2 commits into
cloudwego:mainfrom
wucm667:fix/extra-fields-merge

Conversation

@wucm667
Copy link
Copy Markdown

@wucm667 wucm667 commented Apr 22, 2026

Fixes #671

When multiple WithExtraFields options are passed, later calls overwrite earlier fields instead of merging. This prevents combining framework-provided config (e.g., EnableThinking) with user-provided fields (e.g., enable_search).

Changes

libs/acl/openai/option.go — Changed WithExtraFields to merge fields into o.ExtraFields instead of direct assignment:

// Before (buggy)
o.ExtraFields = extraFields

// After (fixed)
if o.ExtraFields == nil {
    o.ExtraFields = make(map[string]any, len(extraFields))
}
for k, v := range extraFields {
    o.ExtraFields[k] = v
}

libs/acl/openai/option_test.go — Added test case "WithExtraFields merges on multiple calls" verifying that two consecutive calls produce merged fields.

Files Changed

  • libs/acl/openai/option.go
  • libs/acl/openai/option_test.go

When multiple WithExtraFields options are passed, the later call
overwrites the earlier fields instead of merging them. This prevents
combining framework-provided config (like EnableThinking) with
user-provided fields (like enable_search).

Fix by merging extraFields into o.ExtraFields instead of replacing.
@wucm667
Copy link
Copy Markdown
Author

wucm667 commented Apr 22, 2026

Hi! The check-submodule-changes CI job is failing due to a 403 Resource not accessible by integration error when trying to post a comment. This appears to be a permissions issue with the GITHUB_TOKEN in the workflow — it needs issues: write or pull_requests: write permission to create comments on PRs.

All actual tests pass successfully:
✅ unit-test
✅ unit-benchmark-test
✅ compliant
✅ license/cla

Could someone with repo admin access check the workflow permissions? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] WithExtraFields 覆盖而非合并参数,导致 EnableThinking 与其他配置无法共存

1 participant