500 error on generating CSV diffs #7788

Closed
opened 2025-11-02 07:36:32 -06:00 by GiteaMirror · 2 comments
Owner

Originally created by @melmus on GitHub (Sep 2, 2021).

  • Gitea version (or commit ref): v1.15.0
  • Git version: 2.30.2
  • Operating system: Ubuntu 18.04.4 LTS
    Gitea running in docker
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
  • Log gist:

Description

When i create PR in repository, i have 500 error. If i created another branch, and created PR in master branch, everything is fine, but if i see file changed, i have 500 error. This problem i see on one repository.

2021/09/02 12:09:00 ...s/context/context.go:195:HTML() [E] Render failed: template: repo/diff/csv_diff:15:21: executing "repo/diff/csv_diff" at <$cell.Type>: nil pointer evaluating *gitdiff.TableDiffCell.Type

Screenshots

Originally created by @melmus on GitHub (Sep 2, 2021). <!-- NOTE: If your issue is a security concern, please send an email to security@gitea.io instead of opening a public issue --> <!-- 1. Please speak English, this is the language all maintainers can speak and write. 2. Please ask questions or configuration/deploy problems on our Discord server (https://discord.gg/gitea) or forum (https://discourse.gitea.io). 3. Please take a moment to check that your issue doesn't already exist. 4. Make sure it's not mentioned in the FAQ (https://docs.gitea.io/en-us/faq) 5. Please give all relevant information below for bug reports, because incomplete details will be handled as an invalid report. --> - Gitea version (or commit ref): v1.15.0 - Git version: 2.30.2 - Operating system: Ubuntu 18.04.4 LTS Gitea running in docker <!-- Please include information on whether you built gitea yourself, used one of our downloads or are using some other package --> <!-- Please also tell us how you are running gitea, e.g. if it is being run from docker, a command-line, systemd etc. ---> <!-- If you are using a package or systemd tell us what distribution you are using --> - Database (use `[x]`): - [X] PostgreSQL - [ ] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - Log gist: <!-- It really is important to provide pertinent logs --> <!-- Please read https://docs.gitea.io/en-us/logging-configuration/#debugging-problems --> <!-- In addition, if your problem relates to git commands set `RUN_MODE=dev` at the top of app.ini --> ## Description <!-- If using a proxy or a CDN (e.g. CloudFlare) in front of gitea, please disable the proxy/CDN fully and connect to gitea directly to confirm the issue still persists without those services. --> When i create PR in repository, i have 500 error. If i created another branch, and created PR in master branch, everything is fine, but if i see file changed, i have 500 error. This problem i see on one repository. ``` 2021/09/02 12:09:00 ...s/context/context.go:195:HTML() [E] Render failed: template: repo/diff/csv_diff:15:21: executing "repo/diff/csv_diff" at <$cell.Type>: nil pointer evaluating *gitdiff.TableDiffCell.Type ``` ## Screenshots <!-- **If this issue involves the Web Interface, please include a screenshot** -->
GiteaMirror added the type/bugissue/duplicate labels 2025-11-02 07:36:32 -06:00
Author
Owner

@zeripath commented on GitHub (Sep 2, 2021):

It would be helpful if you could upload an example CSV to try.gitea.io.

I think:

diff --git a/templates/repo/diff/csv_diff.tmpl b/templates/repo/diff/csv_diff.tmpl
index b86e9d2a7..b037e29b8 100644
--- a/templates/repo/diff/csv_diff.tmpl
+++ b/templates/repo/diff/csv_diff.tmpl
@@ -12,7 +12,9 @@
 						{{if and (eq $i 0) (eq $j 0)}}
 							<th class="line-num">{{.RowIdx}}</th>
 							{{range $j, $cell := $row.Cells}}
-								{{if eq $cell.Type 2}}
+								{{if not $cell}}
+									<th></th>
+								{{else if eq $cell.Type 2}}
 									<th class="modified"><span class="removed-code">{{.LeftCell}}</span> <span class="added-code">{{.RightCell}}</span></th>
 								{{else if eq $cell.Type 3}}
 									<th class="added"><span class="added-code">{{.LeftCell}}</span></th>
@@ -25,7 +27,9 @@
 						{{else}}
 							<td class="line-num">{{if .RowIdx}}{{.RowIdx}}{{end}}</td>
 							{{range $j, $cell := $row.Cells}}
-								{{if eq $cell.Type 2}}
+								{{if not $cell}}
+									<td></td>
+								{{else if eq $cell.Type 2}}
 									<td class="modified"><span class="removed-code">{{.LeftCell}}</span> <span class="added-code">{{.RightCell}}</span></td>
 								{{else if eq $cell.Type 3}}
 									<td class="added"><span class="added-code">{{.LeftCell}}</span></td>

Would stop the panic but I'm not sure if there is a deeper bug here.

@zeripath commented on GitHub (Sep 2, 2021): It would be helpful if you could upload an example CSV to try.gitea.io. I think: ```patch diff --git a/templates/repo/diff/csv_diff.tmpl b/templates/repo/diff/csv_diff.tmpl index b86e9d2a7..b037e29b8 100644 --- a/templates/repo/diff/csv_diff.tmpl +++ b/templates/repo/diff/csv_diff.tmpl @@ -12,7 +12,9 @@ {{if and (eq $i 0) (eq $j 0)}} <th class="line-num">{{.RowIdx}}</th> {{range $j, $cell := $row.Cells}} - {{if eq $cell.Type 2}} + {{if not $cell}} + <th></th> + {{else if eq $cell.Type 2}} <th class="modified"><span class="removed-code">{{.LeftCell}}</span> <span class="added-code">{{.RightCell}}</span></th> {{else if eq $cell.Type 3}} <th class="added"><span class="added-code">{{.LeftCell}}</span></th> @@ -25,7 +27,9 @@ {{else}} <td class="line-num">{{if .RowIdx}}{{.RowIdx}}{{end}}</td> {{range $j, $cell := $row.Cells}} - {{if eq $cell.Type 2}} + {{if not $cell}} + <td></td> + {{else if eq $cell.Type 2}} <td class="modified"><span class="removed-code">{{.LeftCell}}</span> <span class="added-code">{{.RightCell}}</span></td> {{else if eq $cell.Type 3}} <td class="added"><span class="added-code">{{.LeftCell}}</span></td> ``` Would stop the panic but I'm not sure if there is a deeper bug here.
Author
Owner

@zeripath commented on GitHub (Sep 4, 2021):

Duplicate of #16837

@zeripath commented on GitHub (Sep 4, 2021): Duplicate of #16837
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#7788