@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

When a client submits an overlong "sourcePath", truncate it and continue

Summary:
Ref T13385. Currently, if you run `arc diff` in a CWD with more than 255 characters, the workflow fatals against the length of the `sourcePath` database column.

In the long term, removing this property is likely desirable.

For now, truncate long values and continue. This only meaningfully impacts relatively obscure interactive SVN workflows negatively, and even there, "some arc commands are glitchy in very long working directories in SVN" is still better than "arc diff fatals".

Test Plan:
- Modified `arc` to submit very long source paths.
- Ran `arc diff`.
- Before: Fatal when inserting >255 characters into `sourcePath`.
- After: Path truncated at 255 bytes.

Maniphest Tasks: T13385

Differential Revision: https://secure.phabricator.com/D20727

+18 -1
+18 -1
src/applications/differential/conduit/DifferentialCreateDiffConduitAPIMethod.php
··· 119 119 break; 120 120 } 121 121 122 + $source_path = $request->getValue('sourcePath'); 123 + $source_path = $this->normalizeSourcePath($source_path); 124 + 122 125 $diff_data_dict = array( 123 - 'sourcePath' => $request->getValue('sourcePath'), 126 + 'sourcePath' => $source_path, 124 127 'sourceMachine' => $request->getValue('sourceMachine'), 125 128 'branch' => $request->getValue('branch'), 126 129 'creationMethod' => $request->getValue('creationMethod'), ··· 156 159 'phid' => $diff->getPHID(), 157 160 'uri' => $uri, 158 161 ); 162 + } 163 + 164 + private function normalizeSourcePath($source_path) { 165 + // See T13385. This property is probably headed for deletion. Until we get 166 + // there, stop errors arising from running "arc diff" in a working copy 167 + // with too many characters. 168 + 169 + $max_size = id(new DifferentialDiff()) 170 + ->getColumnMaximumByteLength('sourcePath'); 171 + 172 + return id(new PhutilUTF8StringTruncator()) 173 + ->setMaximumBytes($max_size) 174 + ->setTerminator('') 175 + ->truncateString($source_path); 159 176 } 160 177 161 178 }