mirror of
https://github.com/OpenHands/OpenHands.git
synced 2026-03-22 13:47:19 +08:00
fix: apply ruff lint and format fixes
- Remove unused variable 'original_error' in exception handler - Format long function call arguments across multiple lines Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
@@ -347,7 +347,7 @@ class Runtime(FileEditRuntimeMixin):
|
||||
return self._run_cmd_with_retry(
|
||||
cmd, f'Failed to {context} for env vars {var_names}'
|
||||
)
|
||||
except RuntimeError as original_error:
|
||||
except RuntimeError:
|
||||
# Log the original error at debug level for operators, but redact secret values
|
||||
# We only log the variable names, not the command which contains secrets
|
||||
logger.debug(
|
||||
@@ -438,7 +438,10 @@ class Runtime(FileEditRuntimeMixin):
|
||||
logger.debug(f'Adding env vars to .bashrc: {var_names}')
|
||||
|
||||
self._run_env_cmd_redacted(
|
||||
bashrc_cmd, 'persist environment variables to .bashrc', var_names, is_windows=False
|
||||
bashrc_cmd,
|
||||
'persist environment variables to .bashrc',
|
||||
var_names,
|
||||
is_windows=False,
|
||||
)
|
||||
|
||||
def on_event(self, event: Event) -> None:
|
||||
|
||||
@@ -167,7 +167,9 @@ class TestAddEnvVarsSecretRedaction:
|
||||
|
||||
# Should NOT contain any secret values
|
||||
for secret in secrets.values():
|
||||
assert secret not in error_message, f'Secret "{secret}" leaked in error message'
|
||||
assert secret not in error_message, (
|
||||
f'Secret "{secret}" leaked in error message'
|
||||
)
|
||||
|
||||
# Should contain the variable names (keys) - they get uppercased
|
||||
assert 'API_KEY' in error_message
|
||||
@@ -277,10 +279,12 @@ class TestAddEnvVarsSecretRedaction:
|
||||
runtime = StubRuntime(run_handler=run_handler)
|
||||
|
||||
# Should not raise
|
||||
runtime.add_env_vars({
|
||||
'VALID_VAR_1': 'value1',
|
||||
'VALID_VAR_2': 'value2',
|
||||
})
|
||||
runtime.add_env_vars(
|
||||
{
|
||||
'VALID_VAR_1': 'value1',
|
||||
'VALID_VAR_2': 'value2',
|
||||
}
|
||||
)
|
||||
|
||||
def test_var_names_are_uppercased_in_error(self):
|
||||
"""Test that variable names in errors are uppercased as they would be set."""
|
||||
|
||||
Reference in New Issue
Block a user