fix(service): propagate text_keys to ops via get_init_configs in _set…#960
Merged
Conversation
…up_cfg When cfg is constructed directly from a JSON string in the API path, it bypasses init_configs() and update_op_attr(), causing text_keys (e.g. 'output') to not be injected into each op's text_key parameter. This results in ops using the default text_key 'text', leading to 'NoneType' object is not subscriptable when the dataset field name differs from 'text'. Fix: replace direct Namespace construction with get_init_configs() to ensure full config initialization including op attribute propagation.
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the configuration initialization in service.py by replacing manual Namespace creation with the get_init_configs utility. The review identifies several critical issues with this implementation: it introduces side effects by reconfiguring the global logger on every request, contains a concurrency bug due to fixed temporary file paths in the underlying configuration logic, and fails to handle cases where the configuration is already parsed as a dictionary by FastAPI. A code suggestion was provided to address these issues by handling both data types and using load_configs_only=True.
… race - Call get_init_configs() in _setup_cfg to ensure text_keys is properly propagated to each operator's text_key parameter - Use NamedTemporaryFile with delete=True to avoid race conditions when multiple API requests are processed concurrently
HYLcool
approved these changes
Apr 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…up_cfg
When cfg is constructed directly from a JSON string in the API path, it bypasses init_configs() and update_op_attr(), causing text_keys (e.g. 'output') to not be injected into each op's text_key parameter. This results in ops using the default text_key 'text', leading to 'NoneType' object is not subscriptable when the dataset field name differs from 'text'.
Fix: replace direct Namespace construction with get_init_configs() to ensure full config initialization including op attribute propagation.