Phabricator fails to create a diff if one of the files in the list of changes is empty
Categories
(Conduit :: Phabricator, defect)
Tracking
(Not tracked)
People
(Reporter: vringar, Assigned: vringar)
References
(Regression)
Details
Attachments
(1 external file)
When calling conduit.create_diff() as part of moz-phab submit with a set of changes that contain an empty file, the https://phabricator.services.mozilla.com/api/differential.creatediff endpoint returns the following error:
{
'result':None,
'error_code':'RuntimeException',
'error_info':'array_walk_recursive() expects parameter 1 to be array, null given'
}
| Assignee | ||
Comment 1•5 years ago
|
||
Digging in further into the empty file we find that:
{
'metadata': {},
'oldPath': None,
'currentPath': 'dom/callmonitor/tests/test_actors_child.js',
'awayPaths': [],
'oldProperties': {},
'newProperties': {'unix:filemode': '100644'},
'commitHash': 'b261cdce7563d40d349ae0442d2c2eaef5a7389b',
'type': 1,
'fileType': 1,
'hunks': [
{'oldOffset': 0,
'oldLength': 0,
'newOffset': 1,
'newLength': 0,
'addLines': 0,
'delLines': 0,
'isMissingOldNewline': True,
'isMissingNewNewline': True,
'corpus': '\\ No newline at end of file\n'
}
]
}
The one thing that's curious to me here is that 'newOffset': 1 when it really can't be because there is no line 1 in an empty file.
| Assignee | ||
Comment 2•5 years ago
•
|
||
This was regressed by https://phabricator.services.mozilla.com/D106943 as the call to create_hunk_lines with the defaulted parameter check_eof=True returns the list ['\\ No newline at end of file\n'] which then results in a hunk being generated.
it should be
hunks:[]
As far as I can see there are two options
- Skip creating hunks in
_parse_diff_changeif an empty file is being added. - Modify
create_hunk_linesto return[], Nonewhen given called withbody="",prefix="+"
@Kwan I think 2. is the right approach as sefeng appears to have been working with mercurial when they encountered this bug so just modifying the git code path (aka _parse_diff_change) wouldn't fix that error.
| Assignee | ||
Comment 3•5 years ago
|
||
Updated•5 years ago
|
Updated•5 years ago
|
| Assignee | ||
Updated•5 years ago
|
Description
•