prefer static TransformerName for custom transformer name resolution#1391
Open
gigi206 wants to merge 1 commit into
Open
prefer static TransformerName for custom transformer name resolution#1391gigi206 wants to merge 1 commit into
gigi206 wants to merge 1 commit into
Conversation
registerDefaultTransformersInternal already resolves a built-in transformer's name from `static TransformerName` first, with `instance.name` as a fallback. registerTransformerFromConfig only used `instance.name`, so a custom transformer that follows the same pattern (kebab-case `TransformerName` for config references, descriptive `name` for runtime identity) silently registered under the wrong name and could not be referenced from `transformer.use`. Use the same resolution order in both code paths.
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.
Problem
When a transformer is registered from a file via
transformers: [{ path }], ccr usesinstance.nameas the registry key. The built-in convention inregisterDefaultTransformersInternalis to preferstatic TransformerNamewhen present, and only fall back toinstance.name.This inconsistency bites users who mirror the built-in pattern in their custom transformer:
Config:
{ "transformers": [ { "path": "/path/to/opencode-openai-bearer.js" } ], "Providers": [{ "name": "opencode-openai", "transformer": { "use": ["opencode-openai-bearer"] } }] }Result: the transformer is registered as
OpenCodeOpenAIBearer(instance.name), but the config referencesopencode-openai-bearer(TransformerName).getTransformer("opencode-openai-bearer")returns undefined, the array entry is filtered out, and the provider has an empty transformer list, silently, with no log to point at the cause.Fix
Use the same name resolution order in
registerTransformerFromConfigas in the built-in path: preferstatic TransformerName, fall back toinstance.name. The error message is also clarified to mention both.Empirically verified by reproducing the bug locally with a transformer whose
nameandTransformerNamediffer. Before the patch, the registry logsregister transformer: OpenCodeOpenAIBearerand the provider'susearray is silently empty. After the patch, it logsregister transformer: opencode-openai-bearerand the provider correctly resolves the transformer.Compatibility note
A custom transformer that defined
static TransformerName = "X"andname = "Y"(different values), and that was referenced as "Y" in user configs, would now be registered as "X" instead. This is intentional realignment with the documented built-in pattern, but worth mentioning in case downstream users have come to rely on the previous behaviour.