File comparison displays the message "This file cannot be rendered in your browser" but source view works fine

amelandri December 3, 2014

I'm experiencing this problem with .sql files: I can view the source but when I look at commit details I get the message "This file cannot be rendered in your browser" and if I click on "Diff to previous" I get an endless spinning loading gif.

One strange thing is that while viewing the source, the first character of the first row is a little red dot.
If I move the mouse on the red dot there's a tooltip saying "\uteff"

Is someone experiencing the same problem?

We are using Stash 3.5 64bit on Centos 7

6 answers

1 accepted

3 votes
Answer accepted
Marcin
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 9, 2014

One of the reasons you're seeing issues with the diff is that your SQL files contain a Byte Order Mark (BOM), this is the 0xFEFF sequence you're seeing at the start of the file.  Unfortunately these bytes means git treats the file as binary, not text, and so any operations that depend on git, such as generating a diff, aren't going to return what you expect.

You would also see this behaviour if you did a git diff on some commits in your repo from the command line, as Stash calls out to git for all it's operations:

Binary files a/file.sql and b/file.sql differ

In order for git to properly diff your SQL files you would need to ensure they're saved without the BOM byte, or you could use a git filter to ensure the BOM gets stripped when you commit the file.

As for the issue with "Diff to previous" - that's a real bug in Stash 3.5 with binary files in the source view, I have raised STASH-6866 to track this.

amelandri December 9, 2014

I you are right! After removing the BOM from one of the SQL and commiting several modifications I can use the source comparison. Thank you very much for your help. :-) Now I must find a way to apply a git filter as you suggested. let's got o study. :-) Thank you again. Alessandro

Nope Nope May 6, 2016

What if the BOM is required for build purposes? I tried using .gitattributes to make git treat UTF-16 xml files as text, but they still won't show a diff in the Bitbucket diff despite being able to be displayed in a git diff.

7 votes
ryanvgates January 24, 2019

I was able to resolve the issue by checking "Transcode Diffs". This resolved the issue with comparing sql files.

Bitbucket_Transcode_Diffs_2019-01-24_11-55-48.png

Pravin Sable March 28, 2019

@ryanvgates  Thanks! Your answer is the correct one. No one can go around and remove BOM from the existing files.

Like # people like this
Rowan Dean August 6, 2019

Dare I say ... this is the "BOM"!

Like # people like this
Arun Ramesh August 18, 2020

Worked like a charm! Thanks @Ryan Gates 

Like ryanvgates likes this
0 votes
amelandri December 8, 2014

Done, thank you. I opened the ticket number SSP-6608

Caterina Curti
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 12, 2018

Reviewing SSP-6608, I see that the problem was resolved after removing the BOM at the beginning of the file.

0 votes
Marcin
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 8, 2014

Would it be possible for you to open a support ticket at https://support.atlassian.com/ and attach an example of a file that exhibits this behaviour so that we can try and reproduce the issue?

0 votes
amelandri December 8, 2014

It happens with every SQL file. they are SqlServer 2005 stored procedures

0 votes
Marcin
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 3, 2014

Any kind of SQL files in particular, or all SQL files? That is, are they large, small, what SQL dialect are they? Stash 3.5 introduced changes to syntax highlighting in the file view, so trying to work out what in particular is causing this.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events