Check for valid refs in CommitController before doing anything

Before a 404 would be rendered only after a request to Gitaly would
return with an InvalidArgument error. Now we check that the ref have a
valid format before sending it to Gitaly. In both cases, a 404 is
returned to the user, but this change prevents Gitaly from generating
error noise in production.

Closes gitaly#1425
248 jobs for sh-reject-refs-with-invalid-chars in 38 minutes and 1 second (queued for 11 seconds)
Status Job ID Name Coverage
  Build
manual #132099194
gitlab-org allowed to fail manual
review-docs-deploy-manual
 
  Prepare
passed #132099198
gitlab-org docker
build-qa-image

00:04:33

passed #132099196
gitlab-org
compile-assets

00:07:08

passed #132099195
gitlab-org
retrieve-tests-metadata

00:00:19

passed #132099197
gitlab-org
setup-test-env

00:04:48

 
  Test
passed #132099425
allowed to fail
code_quality

00:08:29

passed #132099200
allowed to fail
danger-review

00:02:10

passed #132099415
gitlab-org
db:check-schema-pg

00:02:12

passed #132099414
gitlab-org
db:migrate:reset-mysql

00:04:54

passed #132099413
gitlab-org
db:migrate:reset-pg

00:03:05

passed #132099419
gitlab-org
db:rollback-mysql

00:04:14

passed #132099418
gitlab-org
db:rollback-pg

00:02:50

passed #132099427
allowed to fail
dependency_scanning

00:05:24

passed #132099409
gitlab-org
docs lint

00:01:33

passed #132099410
gitlab-org
downtime_check

00:01:36

passed #132099412
gitlab-org
ee_compat_check

00:02:36

passed #132099422
gitlab-org-delivery high-cpu
gitlab:assets:compile

00:16:10

passed #132099421
gitlab-org
gitlab:setup-mysql

00:05:54

passed #132099420
gitlab-org
gitlab:setup-pg

00:04:47

passed #132099434
gitlab-org
gitlab_git_test

00:00:21

passed #132099424
gitlab-org
jest

00:09:00

passed #132099423
gitlab-org
karma

00:09:14

58.34%
passed #132100635
gitlab-org
migration:path-mysql

00:12:46

passed #132099416
gitlab-org
migration:path-pg

00:10:46

passed #132099435
gitlab-org
no_ee_check

00:00:21

manual #132099199
allowed to fail manual
package-and-qa
passed #132099432
qa-frontend-node:10

00:08:07

passed #132099430
qa-frontend-node:6

00:12:20

passed #132099431
qa-frontend-node:8

00:11:57

passed #132099433
allowed to fail
qa-frontend-node:latest

00:10:18

passed #132099428
gitlab-org
qa:internal

00:02:40

passed #132099429
gitlab-org
qa:selectors

00:02:31

passed #132100612
gitlab-org
rails4_gemfile_lock_check

00:01:33

passed #132099436
gitlab-org allowed to fail
review-deploy

00:22:02

manual #132099438
gitlab-org docker allowed to fail manual
review-qa-all
failed #132105948
gitlab-org docker allowed to fail
review-qa-smoke

00:02:43

passed #132099441
gitlab-org allowed to fail manual
review-stop

00:00:34

passed #132099251
gitlab-org
rspec-mysql 1/50

00:10:12

passed #132099260
gitlab-org
rspec-mysql 10/50

00:11:59

passed #132099261
gitlab-org
rspec-mysql 11/50

00:13:43

passed #132099262
gitlab-org
rspec-mysql 12/50

00:12:45

passed #132099263
gitlab-org
rspec-mysql 13/50

00:11:41

passed #132099264
gitlab-org
rspec-mysql 14/50

00:13:49

passed #132099265
gitlab-org
rspec-mysql 15/50

00:13:40

passed #132099266
gitlab-org
rspec-mysql 16/50

00:11:19

passed #132099267
gitlab-org
rspec-mysql 17/50

00:11:43

passed #132099268
gitlab-org
rspec-mysql 18/50

00:11:59

passed #132099269
gitlab-org
rspec-mysql 19/50

00:15:10

passed #132099252
gitlab-org
rspec-mysql 2/50

00:11:23

passed #132099270
gitlab-org
rspec-mysql 20/50

00:11:30

passed #132099271
gitlab-org
rspec-mysql 21/50

00:13:39

passed #132099272
gitlab-org
rspec-mysql 22/50

00:12:52

passed #132099273
gitlab-org
rspec-mysql 23/50

00:13:35

passed #132099274
gitlab-org
rspec-mysql 24/50

00:12:56

passed #132099275
gitlab-org
rspec-mysql 25/50

00:12:46

passed #132099276
gitlab-org
rspec-mysql 26/50

00:14:13

passed #132099277
gitlab-org
rspec-mysql 27/50

00:16:00

passed #132099278
gitlab-org
rspec-mysql 28/50

00:13:12

passed #132099279
gitlab-org
rspec-mysql 29/50

00:14:13

passed #132099253
gitlab-org
rspec-mysql 3/50

00:11:22

passed #132099280
gitlab-org
rspec-mysql 30/50

00:14:42

passed #132099281
gitlab-org
rspec-mysql 31/50

00:13:08

passed #132099282
gitlab-org
rspec-mysql 32/50

00:17:06

passed #132099283
gitlab-org
rspec-mysql 33/50

00:11:36

passed #132099284
gitlab-org
rspec-mysql 34/50

00:13:15

passed #132099285
gitlab-org
rspec-mysql 35/50

00:13:42

passed #132099286
gitlab-org
rspec-mysql 36/50

00:12:54

passed #132099287
gitlab-org
rspec-mysql 37/50

00:15:08

passed #132099288
gitlab-org
rspec-mysql 38/50

00:14:55

passed #132099289
gitlab-org
rspec-mysql 39/50

00:14:40

passed #132099254
gitlab-org
rspec-mysql 4/50

00:11:44

passed #132099290
gitlab-org
rspec-mysql 40/50

00:16:44

passed #132099291
gitlab-org
rspec-mysql 41/50

00:13:48

passed #132099292
gitlab-org
rspec-mysql 42/50

00:13:47

passed #132099293
gitlab-org
rspec-mysql 43/50

00:15:14

passed #132099294
gitlab-org
rspec-mysql 44/50

00:14:05

passed #132099295
gitlab-org
rspec-mysql 45/50

00:13:06

passed #132099296
gitlab-org
rspec-mysql 46/50

00:12:23

passed #132099297
gitlab-org
rspec-mysql 47/50

00:16:26

passed #132099298
gitlab-org
rspec-mysql 48/50

00:15:14

passed #132099299
gitlab-org
rspec-mysql 49/50

00:14:01

passed #132099255
gitlab-org
rspec-mysql 5/50

00:11:58

passed #132099300
gitlab-org
rspec-mysql 50/50

00:12:28

passed #132099256
gitlab-org
rspec-mysql 6/50

00:09:51

passed #132099257
gitlab-org
rspec-mysql 7/50

00:08:45

passed #132099258
gitlab-org
rspec-mysql 8/50

00:14:16

passed #132099259
gitlab-org
rspec-mysql 9/50

00:11:25

passed #132099354
gitlab-org
rspec-mysql-rails4 1/50

00:09:23

passed #132099363
gitlab-org
rspec-mysql-rails4 10/50

00:11:52

passed #132099364
gitlab-org
rspec-mysql-rails4 11/50

00:11:46

passed #132099365
gitlab-org
rspec-mysql-rails4 12/50

00:09:32

passed #132099366
gitlab-org
rspec-mysql-rails4 13/50

00:09:44

passed #132099367
gitlab-org
rspec-mysql-rails4 14/50

00:09:57

passed #132099368
gitlab-org
rspec-mysql-rails4 15/50

00:12:07

passed #132099369
gitlab-org
rspec-mysql-rails4 16/50

00:10:26

passed #132099370
gitlab-org
rspec-mysql-rails4 17/50

00:09:26

passed #132099371
gitlab-org
rspec-mysql-rails4 18/50

00:10:49

passed #132099373
gitlab-org
rspec-mysql-rails4 19/50

00:11:18

passed #132099355
gitlab-org
rspec-mysql-rails4 2/50

00:11:00

passed #132099375
gitlab-org
rspec-mysql-rails4 20/50

00:11:09

passed #132099376
gitlab-org
rspec-mysql-rails4 21/50

00:12:32

passed #132099378
gitlab-org
rspec-mysql-rails4 22/50

00:12:16

passed #132099379
gitlab-org
rspec-mysql-rails4 23/50

00:12:12

passed #132099380
gitlab-org
rspec-mysql-rails4 24/50

00:12:00

passed #132099381
gitlab-org
rspec-mysql-rails4 25/50

00:12:24

passed #132099382
gitlab-org
rspec-mysql-rails4 26/50

00:12:56

passed #132099383
gitlab-org
rspec-mysql-rails4 27/50

00:14:51

passed #132099384
gitlab-org
rspec-mysql-rails4 28/50

00:13:24

passed #132099385
gitlab-org
rspec-mysql-rails4 29/50

00:09:49

passed #132099356
gitlab-org
rspec-mysql-rails4 3/50

00:09:51

passed #132099386
gitlab-org
rspec-mysql-rails4 30/50

00:12:03

passed #132099387
gitlab-org
rspec-mysql-rails4 31/50

00:14:08

passed #132099388
gitlab-org
rspec-mysql-rails4 32/50

00:15:57

passed #132099389
gitlab-org
rspec-mysql-rails4 33/50

00:10:58

passed #132099390
gitlab-org
rspec-mysql-rails4 34/50

00:10:42

passed #132099391
gitlab-org
rspec-mysql-rails4 35/50

00:12:32

passed #132099392
gitlab-org
rspec-mysql-rails4 36/50

00:12:47

passed #132099393
gitlab-org
rspec-mysql-rails4 37/50

00:14:01

passed #132099394
gitlab-org
rspec-mysql-rails4 38/50

00:13:10

passed #132099395
gitlab-org
rspec-mysql-rails4 39/50

00:12:05

passed #132099357
gitlab-org
rspec-mysql-rails4 4/50

00:11:04

passed #132099396
gitlab-org
rspec-mysql-rails4 40/50

00:14:13

passed #132099398
gitlab-org
rspec-mysql-rails4 41/50

00:12:19

passed #132099399
gitlab-org
rspec-mysql-rails4 42/50

00:11:50

passed #132099400
gitlab-org
rspec-mysql-rails4 43/50

00:13:57

passed #132099401
gitlab-org
rspec-mysql-rails4 44/50

00:12:45

passed #132099402
gitlab-org
rspec-mysql-rails4 45/50

00:11:51

passed #132099403
gitlab-org
rspec-mysql-rails4 46/50

00:10:59

passed #132099404
gitlab-org
rspec-mysql-rails4 47/50

00:15:33

passed #132099405
gitlab-org
rspec-mysql-rails4 48/50

00:12:44

passed #132099406
gitlab-org
rspec-mysql-rails4 49/50

00:12:28

passed #132099358
gitlab-org
rspec-mysql-rails4 5/50

00:10:31

passed #132099407
gitlab-org
rspec-mysql-rails4 50/50

00:12:10

passed #132099359
gitlab-org
rspec-mysql-rails4 6/50

00:08:50

passed #132099360
gitlab-org
rspec-mysql-rails4 7/50

00:08:01

passed #132099361
gitlab-org
rspec-mysql-rails4 8/50

00:14:09

passed #132099362
gitlab-org
rspec-mysql-rails4 9/50

00:11:05

passed #132099201
gitlab-org
rspec-pg 1/50

00:10:29

passed #132099210
gitlab-org
rspec-pg 10/50

00:10:27

passed #132099211
gitlab-org
rspec-pg 11/50

00:12:29

passed #132099212
gitlab-org
rspec-pg 12/50

00:10:39

passed #132099213
gitlab-org
rspec-pg 13/50

00:10:49

passed #132099214
gitlab-org
rspec-pg 14/50

00:12:06

passed #132099215
gitlab-org
rspec-pg 15/50

00:13:40

passed #132099216
gitlab-org
rspec-pg 16/50

00:11:44

passed #132099217
gitlab-org
rspec-pg 17/50

00:11:17

passed #132099218
gitlab-org
rspec-pg 18/50

00:11:17

passed #132099219
gitlab-org
rspec-pg 19/50

00:12:46

passed #132099202
gitlab-org
rspec-pg 2/50

00:11:07

passed #132099220
gitlab-org
rspec-pg 20/50

00:11:15

passed #132099221
gitlab-org
rspec-pg 21/50

00:12:08

passed #132099222
gitlab-org
rspec-pg 22/50

00:11:43

passed #132099223
gitlab-org
rspec-pg 23/50

00:12:20

passed #132099224
gitlab-org
rspec-pg 24/50

00:13:05

passed #132099225
gitlab-org
rspec-pg 25/50

00:11:20

passed #132099226
gitlab-org
rspec-pg 26/50

00:12:35

passed #132099227
gitlab-org
rspec-pg 27/50

00:11:21

passed #132099228
gitlab-org
rspec-pg 28/50

00:12:47

passed #132099229
gitlab-org
rspec-pg 29/50

00:13:27

passed #132099203
gitlab-org
rspec-pg 3/50

00:14:20

passed #132099230
gitlab-org
rspec-pg 30/50

00:12:50

passed #132099231
gitlab-org
rspec-pg 31/50

00:11:43

passed #132099232
gitlab-org
rspec-pg 32/50

00:11:32

passed #132099233
gitlab-org
rspec-pg 33/50

00:12:20

passed #132099234
gitlab-org
rspec-pg 34/50

00:11:40

passed #132099235
gitlab-org
rspec-pg 35/50

00:12:07

passed #132099236
gitlab-org
rspec-pg 36/50

00:11:23

passed #132099237
gitlab-org
rspec-pg 37/50

00:13:31

passed #132099238
gitlab-org
rspec-pg 38/50

00:12:54

passed #132099239
gitlab-org
rspec-pg 39/50

00:12:44

passed #132099204
gitlab-org
rspec-pg 4/50

00:10:55

passed #132099240
gitlab-org
rspec-pg 40/50

00:12:04

passed #132099241
gitlab-org
rspec-pg 41/50

00:11:58

passed #132099242
gitlab-org
rspec-pg 42/50

00:13:16

passed #132099243
gitlab-org
rspec-pg 43/50

00:12:22

passed #132099244
gitlab-org
rspec-pg 44/50

00:12:18

passed #132099245
gitlab-org
rspec-pg 45/50

00:13:19

passed #132099246
gitlab-org
rspec-pg 46/50

00:11:18

passed #132099247
gitlab-org
rspec-pg 47/50

00:13:52

passed #132099248
gitlab-org
rspec-pg 48/50

00:12:22

passed #132099249
gitlab-org
rspec-pg 49/50

00:13:10

passed #132099205
gitlab-org
rspec-pg 5/50

00:10:18

passed #132102237
gitlab-org
rspec-pg 50/50

00:11:36

passed #132099206
gitlab-org
rspec-pg 6/50

00:12:58

passed #132099207
gitlab-org
rspec-pg 7/50

00:10:41

passed #132099208
gitlab-org
rspec-pg 8/50

00:14:31

passed #132099209
gitlab-org
rspec-pg 9/50

00:12:04

passed #132099301
gitlab-org
rspec-pg-rails4 1/50

00:10:04

passed #132099310
gitlab-org
rspec-pg-rails4 10/50

00:10:44

passed #132099311
gitlab-org
rspec-pg-rails4 11/50

00:10:47

passed #132099312
gitlab-org
rspec-pg-rails4 12/50

00:09:10

passed #132099313
gitlab-org
rspec-pg-rails4 13/50

00:11:12

passed #132099314
gitlab-org
rspec-pg-rails4 14/50

00:08:51

passed #132099315
gitlab-org
rspec-pg-rails4 15/50

00:11:44

passed #132099316
gitlab-org
rspec-pg-rails4 16/50

00:10:04

passed #132099317
gitlab-org
rspec-pg-rails4 17/50

00:10:24

passed #132099318
gitlab-org
rspec-pg-rails4 18/50

00:10:03

passed #132099319
gitlab-org
rspec-pg-rails4 19/50

00:09:47

passed #132099302
gitlab-org
rspec-pg-rails4 2/50

00:11:01

passed #132099320
gitlab-org
rspec-pg-rails4 20/50

00:10:42

passed #132099321
gitlab-org
rspec-pg-rails4 21/50

00:12:09

passed #132099322
gitlab-org
rspec-pg-rails4 22/50

00:10:00

passed #132099323
gitlab-org
rspec-pg-rails4 23/50

00:12:15

passed #132099325
gitlab-org
rspec-pg-rails4 24/50

00:11:03

passed #132099328
gitlab-org
rspec-pg-rails4 25/50

00:10:27

passed #132099329
gitlab-org
rspec-pg-rails4 26/50

00:10:18

passed #132099330
gitlab-org
rspec-pg-rails4 27/50

00:12:23

passed #132099331
gitlab-org
rspec-pg-rails4 28/50

00:11:42

passed #132099332
gitlab-org
rspec-pg-rails4 29/50

00:10:59

passed #132099303
gitlab-org
rspec-pg-rails4 3/50

00:10:01

passed #132099333
gitlab-org
rspec-pg-rails4 30/50

00:11:25

passed #132099334
gitlab-org
rspec-pg-rails4 31/50

00:10:07

passed #132099335
gitlab-org
rspec-pg-rails4 32/50

00:12:44

passed #132099336
gitlab-org
rspec-pg-rails4 33/50

00:10:11

passed #132099337
gitlab-org
rspec-pg-rails4 34/50

00:10:11

passed #132099338
gitlab-org
rspec-pg-rails4 35/50

00:10:58

passed #132099339
gitlab-org
rspec-pg-rails4 36/50

00:11:25

passed #132099340
gitlab-org
rspec-pg-rails4 37/50

00:11:40

passed #132099341
gitlab-org
rspec-pg-rails4 38/50

00:11:13

passed #132099342
gitlab-org
rspec-pg-rails4 39/50

00:10:52

passed #132099304
gitlab-org
rspec-pg-rails4 4/50

00:10:54

passed #132099343
gitlab-org
rspec-pg-rails4 40/50

00:10:04

passed #132099344
gitlab-org
rspec-pg-rails4 41/50

00:10:50

passed #132099345
gitlab-org
rspec-pg-rails4 42/50

00:10:16

passed #132099346
gitlab-org
rspec-pg-rails4 43/50

00:11:45

passed #132099347
gitlab-org
rspec-pg-rails4 44/50

00:11:27

passed #132099348
gitlab-org
rspec-pg-rails4 45/50

00:11:38

passed #132099349
gitlab-org
rspec-pg-rails4 46/50

00:10:45

passed #132099350
gitlab-org
rspec-pg-rails4 47/50

00:11:24

passed #132099351
gitlab-org
rspec-pg-rails4 48/50

00:11:05

passed #132099352
gitlab-org
rspec-pg-rails4 49/50

00:12:13

passed #132099305
gitlab-org
rspec-pg-rails4 5/50

00:10:15

passed #132099353
gitlab-org
rspec-pg-rails4 50/50

00:12:10

passed #132099306
gitlab-org
rspec-pg-rails4 6/50

00:09:16

passed #132099307
gitlab-org
rspec-pg-rails4 7/50

00:07:46

passed #132099308
gitlab-org
rspec-pg-rails4 8/50

00:13:11

passed #132099309
gitlab-org
rspec-pg-rails4 9/50

00:10:35

passed #132099426
allowed to fail
sast

00:04:06

passed #132099408
gitlab-org
static-analysis

00:09:55

failed #132099417
gitlab-org
migration:path-mysql

00:00:42

failed #132099411
gitlab-org
rails4_gemfile_lock_check

00:00:37

failed #132105481
docker gitlab-org allowed to fail
review-qa-smoke

00:02:53

failed #132099437
gitlab-org docker allowed to fail
review-qa-smoke

00:24:13

failed #132099250
gitlab-org
rspec-pg 50/50

00:12:09

 
  Post Test
passed #132099444
gitlab-org
coverage

00:03:38

100.0%
failed #132099443
gitlab-org allowed to fail
flaky-examples-check

00:02:03

passed #132099445
gitlab-org
lint:javascript:report

00:00:46

 
  Post Cleanup
manual #132099446
gitlab-org allowed to fail manual
review-docs-cleanup
 
Name Stage Failure
failed
review-qa-smoke Test
Randomized with seed 63666

Running after script...
$ date
Mon Dec 10 06:34:57 UTC 2018
Uploading artifacts...
./qa/gitlab-qa-run-*: found 8 matching files
Uploading artifacts to coordinator... ok
id=132105948 responseStatus=201 Created token=3T-Aityv
ERROR: Job failed: exit code 1
failed
flaky-examples-check Post Test
    "first_flaky_at": "2018-12-10 06:11:46 +0000",
"last_flaky_at": "2018-12-10 06:11:46 +0000",
"last_flaky_job": "https://gitlab.com/gitlab-org/gitlab-ce/-/jobs/132099346"
}
}
Running after script...
$ date
Mon Dec 10 06:37:01 UTC 2018
ERROR: Job failed: exit code 1