fix(forge): issue view lists the files attached to an issue and its comments #298
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/upscaling
beanstalk: approved @ 1697603
beanstalk: approved @ 2c5a62e
beanstalk: approved @ 4fd82b7
beanstalk: approved @ 64d6d09
beanstalk: approved @ 6f91fae
beanstalk: approved @ 70a78f9
beanstalk: approved @ 8015c9a
beanstalk: approved @ 8d361dc
beanstalk: approved @ 9d8356e
beanstalk: approved @ abf2227
beanstalk: approved @ d82f202
beanstalk: approved @ e5f1e40
beanstalk: approved @ ee8ab5f
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
testing wanted
ci: approved
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!298
Loading…
Reference in a new issue
No description provided.
Delete branch "Amateurwizrd/Longshot:fix/forge-issue-view-attachments"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Type: fix · Risk: low · Tested on: Windows 11 (no GPU involved) · Needs: none
Why
A bug report's log is usually an attachment, and
forge.py issue viewprinted only the issue's text, so a report with a log read as if it had none. Fixes #289.How to reproduce
Seen on: Windows 11, any GPU (a script, no game)
Settings and switches: defaults, signed in with
forge.py loginSteps:
python -I scripts/forge.py issue view 278, thenpython -I scripts/forge.py issue view 261 --commentsExpected: both logs on 278, and the six files on 261 (one on the issue, five on a comment), each with a link
Actual: on main, no files are listed at all
What changed
issue view(and--comments) now lists each file attached to the issue and to each comment by name, size and link, without downloading anything. Names and links are escaped so a hostile or odd filename can't break the terminal or the output's lines.show_attachments()inscripts/forge.pyprintsattached: "NAME" (SIZE) LINK, the name and link JSON-escaped (the formatting of #300'sd39f01dd), so a newline, ESC or CR/LF stays one printable line and a name a cp1252 pipe can't take still prints.cmd_issuecalls it for the issue andshow_comments()for each comment. It reads theassetslist the two GETs already return: no new request.pr comment --attachleaves), sopr view N --commentsreads as before for those.docs/forge.md, and the usage line inscripts/forge.py.test_issue_view_lists_the_attachmentsandtest_attachment_names_and_links_are_escapedintests/test_forge_pr.py; its stand-in Forgejo now answersGET /issues/N.Measurements
Verdict: it works: issue 278 lists its 2 logs and 261 its 6 files (0 on main),
pr view 292 --commentsunchanged, and the two new tests fail on main and pass here.Hardware: none involved (a script and its test); run on Windows 11 with Python 3 from the builder's tools
Scene: none; the tracker's issues 278 and 261, read with a signed-in session
Method: the command's output on each side, counted with
grep -c "^attached:", each command run twice on each side, alternated, with the same count both times (the output does not vary); the new test run on each sideHow to reproduce:
python -I scripts/forge.py issue view 278,python -I scripts/forge.py issue view 261 --comments,python -I -B tests/test_forge_pr.py9e6f231d7892cefaissue view 278: attached files listedissue view 261 --comments: attached files listedpr view 292 --comments(a comment with 4 pictures put up by--attach): attached files listedtests/test_forge_pr.pywith this PR's teststhis PR @
7892cefa,issue view 278(the lines it adds):The new tests on main @
9e6f231d(this PR'stests/test_forge_pr.pywith main'sscripts/forge.py):and on this PR:
Flags and settings
None.
Testing
Tested: on Windows 11.
python -I -B tests/test_forge_pr.py: 34 pass, including the escape test (newline, ESC and CR/LF in a name or link, and a CJK name into a cp1252 pipe, in the issue's rows and a comment's).tests/test_forge_session_lock.pyandtests/test_check_pr_description.pypass.python -I -B tests/run_all.pywithCXX=g++(this PC has no llvm-mingw at the moment): 475 passed, 39 failed, 79 skipped, the same failures as main @9e6f231don this PC, all toolchain or environment checks this PR doesn't touch:test_appimage_player_build.py,test_bake_portability.py,test_control_pipe_security.py,test_cpm_discovery.py,test_cpp_preflight.py,test_crash_dialog.py,test_env_on.py,test_exclusive_marks.py,test_fpx_sticky.py,test_gpu_hang_watch.py,test_lift_cleanup_error.py,test_linux_preflight.py,test_lower_depbar.py,test_lower_lds_after_sts.py,test_lower_register_markers.py,test_make_game_cache.py,test_make_game_prepare.py,test_missing_nup.py,test_native_suatom.py,test_nvn_null_pool.py,test_nvn_tex_builder_guard.py,test_nvn_texture_handle.py,test_oot_state_tap.py,test_options_budget_once.py,test_pipeline_cache_file.py,test_pipeline_play_cache.py,test_portable_builder_home.py,test_portable_builder_startup.py,test_precompile_compute_guard.py,test_prepare_stall.py,test_readback_late.py,test_rt_pool_minimum.py,test_shader_module_guard.py,test_spawn_emit.py,test_split_giants.py,test_tested_configurations.py,test_utf8_paths.py,test_vk_pgo.py,test_walk_key.py.Not tested: the game (no game code changes). Linux (standard-library Python, no path or console handling). An attachment the signed-in user may not read: the link is printed as the API gives it. A pull request's own attachments:
pr viewdoes not list them, before or after.Must be tested: None.
Risks
What could break:
issue viewand--commentsprint extra lines for issues and comments with files; a script parsing that output would see them. Nothing is written or fetched.Turning it off: revert the commit.
Compatibility: Nothing changes.
Issues
Fixes #289
Checklist
Everyone
type(scope): description) of the status line's type.main.python -I -B tests/run_all.pypasses (any failure that also fails onmainis named).third_party/untouched (a new folder with aPROVENANCE.mdinstead).When it applies
Assisted-by:/Co-Authored-By:trailers.mainand passing here.tests/that reads changed source updated in this PR, not weakened.dc8d9397, an otherwise ASCII issue with a CJK attachment name raises UnicodeEncodeError in a cp1252 pipe at show_attachments, so the command stops instead of displaying the log link. A filename containing newline/ESC and a URL containing CR/LF also reach the terminal unchanged. Two native Windows interleaved pairs of the same guarded CLI fixtures reproduce both behaviors here; the equivalent formatting in PR300 passes both each time. Please add lossless escaping/quoting and regression coverage for both issue and comment attachment rows. PR120's broader UTF-8 stream setup is separate and does not escape terminal controls.This is a focused display review, not a full-suite or attachment-download claim. The two checks used authored API data and the existing no-network guards; no attachment content was fetched.
This PR and my PR300 overlap on issue289. I have put PR300 back in WIP and preserved its branch/evidence so only one implementation proceeds. This broader PR's comment-attachment coverage is useful; please reuse equivalent safe formatting and boundary tests from commit
d39f01dd9drather than merge both implementations unchanged.@ -289,0 +293,4 @@for a in item.get("assets") or []:size, link = a.get("size") or 0, a["browser_download_url"]if link not in (item.get("body") or ""):print("attached: %s (%s) %s" % (a["name"], "%d bytes" % size if size < 1024 else "%.1f KiB" % (size / 1024)Please escape or quote attachment names and URLs before printing. Native guarded cases reproduce UnicodeEncodeError for a CJK name in a cp1252 pipe and raw newline/ESC/CRLF output. PR300 has passing regression coverage and safe formatting to reuse.
dc8d93979f7892cefa3dRebased onto main
9e6f231dand took monsterlag's review: attachment names are quoted and both name and link JSON-escaped (the formatting of #300'sd39f01dd), so a newline, ESC or CR/LF stays one printable line and a CJK name prints into a cp1252 pipe. New test test_attachment_names_and_links_are_escaped covers issue and comment rows; it fails on main and passes here. Re-measured on the live tracker at7892cefa: 278 lists 2, 261 --comments lists 6, as before. run_all: no failure that main9e6f231ddoesn't also have on this PC.Description moved to main's new template (status line, How to reproduce, Verdict, Risks, Must be tested); content unchanged apart from that.
@monsterlag your review is addressed in
7892cefa(escaping as in yourd39f01dd, with a test for issue and comment rows); ready for another look.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.