sync
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 57s
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 57s
This commit is contained in:
@@ -148,10 +148,19 @@ class ConfigManager:
|
||||
logger.info("No configuration found in Consul at key: %s", full_config_key)
|
||||
return
|
||||
|
||||
# Value is base64 encoded JSON
|
||||
encoded_value = data['Value']
|
||||
logger.debug(f"Consul raw value type: {type(encoded_value)}, value: {encoded_value[:50]}...") # Log type and first 50 chars
|
||||
logger.debug(f"Consul encoded value: {encoded_value}")
|
||||
# Value from Consul might be raw bytes of the JSON, or it might be base64 encoded.
|
||||
# We'll try to decode directly first, and fall back to base64.
|
||||
raw_value_from_consul = data['Value'] # This should be bytes
|
||||
logger.debug(f"Consul raw value type: {type(raw_value_from_consul)}, value (first 100 bytes): {raw_value_from_consul[:100]}...")
|
||||
|
||||
try:
|
||||
# Attempt 1: Assume the value is the direct UTF-8 bytes of the JSON string.
|
||||
decoded_json_str = raw_value_from_consul.decode('utf-8')
|
||||
logger.info("Successfully decoded Consul value directly as UTF-8.")
|
||||
except UnicodeDecodeError:
|
||||
logger.warning("Direct UTF-8 decoding failed. Falling back to base64 decoding.")
|
||||
# Attempt 2: Assume the value is base64 encoded.
|
||||
encoded_value = raw_value_from_consul
|
||||
|
||||
# Add padding if necessary for base64 decoding
|
||||
padding_needed = len(encoded_value) % 4
|
||||
@@ -159,7 +168,9 @@ class ConfigManager:
|
||||
encoded_value += b'=' * (4 - padding_needed)
|
||||
|
||||
decoded_json_str = base64.b64decode(encoded_value).decode('utf-8')
|
||||
logger.debug(f"Consul decoded JSON string: {decoded_json_str}")
|
||||
logger.info("Successfully decoded Consul value using base64 fallback.")
|
||||
|
||||
logger.debug(f"Decoded JSON string: {decoded_json_str}")
|
||||
consul_conf = json.loads(decoded_json_str) # Parse the JSON
|
||||
logger.debug(f"Consul parsed config (dict): {consul_conf}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user