Page MenuHomePhabricator

DiffusionRefNotFoundException when displaying a branch containing a slash ("/") character
Closed, InvalidPublic

Description

Repro steps

  1. Create a new Git branch with a "/" character, e.g. "foo/bar"; push it to a Phabricator-hosted repo
  2. In Diffusion, browse to the repo, scroll to the "branches" section, click on the "foo/bar" link.

Expected behaviour

Phabricator displays the contents of the branch.

Actual behaviour

Unhandled Exception ("DiffusionRefNotFoundException")
Ref "foo" does not exist in this repository.

Version info

phabricator ad65d933fa75a2c417ba23f3684f0109de0f6ace (Sat, Dec 3)
arcanist e17fe43ca3fe6dc6dd0b5ce056f56310ea1d3d51 (Oct 22 2016)
phutil 3230179f3ce5d144a5fcdd5d68375f285006bd58 (Sat, Dec 3)

Event Timeline

Can you show me:

  • the RewriteRule entries in your httpd.conf; and
  • the output of httpd -v (or similar)?

We use nginx:

$ nginx -v
nginx version: nginx/1.10.2
/etc/nginx/sites-available/phabricator
client_max_body_size 32M;

map $http_upgrade $connection_upgrade {
    default upgrade;
    '' close;
}

server {
    server_name phabricator.mycompany.com phabricatorusercontent.mycompany.com;
    root        /srv/phabricator/phabricator/webroot;

    location / {
        try_files $uri /index.php?__path__=$uri&$query_string;
    }

    location = /favicon.ico {
        try_files $uri =204;
    }

    location = /index.php {
        if ($args !~ __path__) {
          set $args __path__=$uri&$query_string;
        }
        fastcgi_pass unix:/var/run/php-fpm/www.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }

    location = /ws/ {
        proxy_pass http://127.0.0.1:22280;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
    }
}

The problematic URLs look like this:

http://phabricator.mycompany.com/diffusion/MYREPO/browse/foo%252Fbar/

Your config looks very little like the config we recommend. Why are you using try_files instead of rewrite?

When your webserver is configured correctly, branch names containing slashes should work properly. I believe you've deviated from the documented configuration in a way that changes behavior for URI-escaped parameters.

Here's an example of this working correctly on this server:

https://secure.phabricator.com/diffusion/GITTEST/browse/foo%252Fbar/

See also T11553.

I'm going to close this since it isn't reproducible (e.g., the link above works fine) and I'm fairly confident that this is a configuration problem in how you've adjusted nginx to work, deviating from the upstream instructions.

In T11553, D12622 added a setup check which tests for this class of misconfiguration.

Feel free to file a new bug report if this doesn't resolve your issues, but you need to reproduce the issue with a configuration similar to the one we recommend in the documentation before we can fix it. Obviously, if you write your own configuration there are a million ways you can break things, and we can't support all possible configurations.

In particular, your configuration unescaping the request too many times. When the browser sends a request for /foo%252Fbar/, we expect to receive a request for /foo%2Fbar/ in the application. Instead, escaping is being interpreted too many times and we are receiving a request for /foo/bar/, which we treat as a request for the branch named "foo".

Thanks for pointing me in the right direction -- this was indeed pilot error. Switching to rewrite as stated in the install guide fixes the error.