Fix #2061 — Remote configuration silently disabled on self-provisioning gateways#2139
Open
apachler wants to merge 1 commit into
Open
Fix #2061 — Remote configuration silently disabled on self-provisioning gateways#2139apachler wants to merge 1 commit into
apachler wants to merge 1 commit into
Conversation
…sboard#2061) A gateway that authenticates via the `provisioning` section has no `security` section in its configuration (credentials are obtained at runtime and stored in provisioned_credentials.json; TBClient never writes them back into the config). RemoteConfigurator init calls _get_general_config_in_local_format(), which dereferenced the missing security section (security_section.get('type')) and raised AttributeError. __init_remote_configuration swallows that exception, so __remote_configurator stayed None: the config-request consumer thread never started, the gateway never sent its configuration to ThingsBoard, and every remote update (connector adds, remote logging, etc.) was silently dropped. - Guard the security-section normalization so it is skipped when no security section is present. - Treat two empty/absent security sections as a match in __is_security_match, so provisioning gateways no longer force a needless reconnect on every general_configuration push, and never dereference None when only one side has a section.
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 gateway authenticates via the provisioning section (self-onboarding), remote configuration is silently non-functional: enabling remote logging, changing settings, or adding a connector from the ThingsBoard
gateway dashboard has no effect and nothing is persisted to disk. The only visible hint is an unrelated Unexpected message from topic 'v1/devices/me/attributes' debug line (benign SDK noise — the payload is delivered).
Root cause
A provisioning gateway has no security section in its configuration — credentials are obtained at runtime and stored separately in provisioned_credentials.json, and TBClient never writes them back into the config.
RemoteConfigurator.init calls _get_general_config_in_local_format(), which assumed a security section always exists:
security_section = adopted_general_config.get('security') # -> None for a provisioning gateway
security_type = security_section.get('type', 'accessToken') # -> AttributeError: 'NoneType' object has no attribute 'get'
That AttributeError is caught and swallowed by TBGatewayService.__init_remote_configuration, leaving __remote_configurator = None. As a result:
A secondary issue affects the same gateways: __is_security_match(None, …) returns False, so once initialized, every general_configuration push forces a full reconnect via _apply_connection_config (consistent with the
reconnect churn reported in #2124).
Fix
thingsboard_gateway/tb_utility/tb_gateway_remote_configurator.py:
No public API or config-format changes; behavior is unchanged for gateways that use an explicit security section.
How to reproduce (before this PR)
Testing
Compatibility
Backward compatible. Gateways using accessToken / usernamePassword / tlsAccessToken are unaffected; only the previously-crashing no-security (provisioning) path changes.
Closes #2061.