Skip to content

Commit 5169656

Browse files
fix(oauth): always emit control message to stdout for token persistence
Control messages for config updates (like refreshed tokens) must be printed directly to stdout so the platform can process them immediately. Previously, when using InMemoryMessageRepository, control messages were only queued but never output to stdout, causing single-use refresh tokens to not be persisted. This fix ensures emit_configuration_as_airbyte_control_message() is always called to print to stdout, while also emitting to the message repository for any additional processing. Co-Authored-By: aldo.gonzalez@airbyte.io <aldo.gonzalez@airbyte.io>
1 parent 0828d04 commit 5169656

1 file changed

Lines changed: 11 additions & 14 deletions

File tree

  • airbyte_cdk/sources/streams/http/requests_native_auth

airbyte_cdk/sources/streams/http/requests_native_auth/oauth.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -383,27 +383,24 @@ def _emit_control_message(self) -> None:
383383
"""
384384
Emits a control message based on the connector configuration.
385385
386-
This method checks if the message repository is not a NoopMessageRepository.
387-
If it is not, it emits a message using the message repository. Otherwise,
388-
it falls back to emitting the configuration as an Airbyte control message
389-
directly to the console for backward compatibility.
386+
Control messages for config updates (like refreshed tokens) must be printed directly
387+
to stdout so the platform can process them immediately. The message repository is
388+
also used to queue the message for any additional processing.
390389
391390
Note:
392-
The function `emit_configuration_as_airbyte_control_message` has been deprecated
393-
in favor of the package `airbyte_cdk.sources.message`.
394-
395-
Raises:
396-
TypeError: If the argument types are incorrect.
391+
The function `emit_configuration_as_airbyte_control_message` prints directly to
392+
stdout, which is required for the platform to detect and persist config changes.
397393
"""
398-
# FIXME emit_configuration_as_airbyte_control_message as been deprecated in favor of package airbyte_cdk.sources.message
399-
# Usually, a class shouldn't care about the implementation details but to keep backward compatibility where we print the
400-
# message directly in the console, this is needed
394+
# Always emit to stdout so the platform can process the config update immediately.
395+
# This is critical for single-use refresh tokens where the new token must be persisted
396+
# before subsequent operations try to use the old (now invalid) token.
397+
emit_configuration_as_airbyte_control_message(self._connector_config) # type: ignore[arg-type]
398+
399+
# Also emit to the message repository for any additional processing (e.g., logging)
401400
if not isinstance(self._message_repository, NoopMessageRepository):
402401
self._message_repository.emit_message(
403402
create_connector_config_control_message(self._connector_config) # type: ignore[arg-type]
404403
)
405-
else:
406-
emit_configuration_as_airbyte_control_message(self._connector_config) # type: ignore[arg-type]
407404

408405
@property
409406
def _message_repository(self) -> MessageRepository:

0 commit comments

Comments
 (0)