Spaces:
Running
Running
Update config_provider.py
Browse files- config_provider.py +17 -12
config_provider.py
CHANGED
@@ -411,18 +411,8 @@ class ConfigProvider:
|
|
411 |
if not cls._CONFIG_PATH.exists():
|
412 |
raise FileNotFoundError(f"Config file not found: {cls._CONFIG_PATH}")
|
413 |
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
# Try commentjson first, fallback to manual cleaning
|
418 |
-
try:
|
419 |
-
with open(cls._CONFIG_PATH, 'r', encoding='utf-8') as f:
|
420 |
-
config_data = commentjson.load(f)
|
421 |
-
except Exception as e:
|
422 |
-
log(f"⚠️ commentjson failed ({str(e)[:100]}...), trying manual JSON cleaning...")
|
423 |
-
# Manual cleaning - remove comments and trailing commas
|
424 |
-
cleaned = cls._strip_jsonc(raw_content)
|
425 |
-
config_data = json.loads(cleaned)
|
426 |
|
427 |
# Ensure required fields exist in config data
|
428 |
if 'config' not in config_data:
|
@@ -450,6 +440,21 @@ class ConfigProvider:
|
|
450 |
|
451 |
# Parse auth configs
|
452 |
if 'auth' in api and api['auth']:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
453 |
if 'body_template' in api['auth'] and isinstance(api['auth']['body_template'], str):
|
454 |
try:
|
455 |
api['auth']['token_request_body'] = json.loads(api['auth']['body_template'])
|
|
|
411 |
if not cls._CONFIG_PATH.exists():
|
412 |
raise FileNotFoundError(f"Config file not found: {cls._CONFIG_PATH}")
|
413 |
|
414 |
+
with open(cls._CONFIG_PATH, 'r', encoding='utf-8') as f:
|
415 |
+
config_data = commentjson.load(f)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
416 |
|
417 |
# Ensure required fields exist in config data
|
418 |
if 'config' not in config_data:
|
|
|
440 |
|
441 |
# Parse auth configs
|
442 |
if 'auth' in api and api['auth']:
|
443 |
+
# token_request_body string ise dict'e çevir
|
444 |
+
if 'token_request_body' in api['auth'] and isinstance(api['auth']['token_request_body'], str):
|
445 |
+
try:
|
446 |
+
api['auth']['token_request_body'] = json.loads(api['auth']['token_request_body'])
|
447 |
+
except:
|
448 |
+
api['auth']['token_request_body'] = {}
|
449 |
+
|
450 |
+
# token_refresh_body string ise dict'e çevir
|
451 |
+
if 'token_refresh_body' in api['auth'] and isinstance(api['auth']['token_refresh_body'], str):
|
452 |
+
try:
|
453 |
+
api['auth']['token_refresh_body'] = json.loads(api['auth']['token_refresh_body'])
|
454 |
+
except:
|
455 |
+
api['auth']['token_refresh_body'] = {}
|
456 |
+
|
457 |
+
# Eski body_template alanı için backward compatibility
|
458 |
if 'body_template' in api['auth'] and isinstance(api['auth']['body_template'], str):
|
459 |
try:
|
460 |
api['auth']['token_request_body'] = json.loads(api['auth']['body_template'])
|