Skip to content

fix: order logs rendering#2423

Open
alicecoordinator wants to merge 2 commits intoRoboSats:mainfrom
alicecoordinator:fix-order-logs-rendering
Open

fix: order logs rendering#2423
alicecoordinator wants to merge 2 commits intoRoboSats:mainfrom
alicecoordinator:fix-order-logs-rendering

Conversation

@alicecoordinator
Copy link
Copy Markdown
Contributor

@alicecoordinator alicecoordinator commented Feb 10, 2026

What does this PR do?

Fixes error while rendering order logs.
image

In api/logics.py, the log line was being added without interpolation, so the exact string below was added to the logs:

Robot({slashed_robot.id},{slashed_robot.user.username}) was returned {slashed_return} Sats)

When this log was rendered, the function format_html would try to interpolate values within brackets (slashed_robot), and would fail because no argument is being passed.

It would only make sense to use format_html if we are passing arguments like this:

# evaluates to <div>Hello &lt;3</div>
format_html('<div>{escaped}</div>', escaped='Hello <3')

Checklist before merging

  • Install pre-commit and initialize it: pip install pre-commit, then pre-commit install. Pre-commit installs git hooks that automatically check the codebase. If pre-commit fails when you commit your changes, please fix the problems it points out.

jerryfletcher21 and others added 2 commits March 9, 2026 14:15
`slashed_robot_log` was not expanded so it resulted in a literal
`{slashed_robot.id}` ecc. and `_logs` in `api/admin.py` threw an
exception here:
```python
with_hyperlinks = objects_to_hyperlinks(obj.logs)
try:
    html_logs = format_html(
        f'<table style="width: 100%">{with_hyperlinks}</table>'
    )
except Exception as e:
    html_logs = f"An error occurred while formatting the parsed logs as HTML. Exception {e}"
```

Also removed a trailing parenthesis.
@alicecoordinator alicecoordinator force-pushed the fix-order-logs-rendering branch from 8087695 to e3a11c7 Compare March 9, 2026 14:16
@alicecoordinator
Copy link
Copy Markdown
Contributor Author

@jerryfletcher21 I cherry picked the commit from your branch, and rebased my branch. Would you mind submitting an approval just for documentation purposes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants