Repository: rucio/rucio

Issue:
Improve error message for PFN mismatch
Motivation
----------
Sometimes we get the error in panda for our jobs:

```
ddm, 200: Could not add files to DDM: Details: [u"One of the PFNs provided does not match the Rucio expected PFN : [u'gsiftp://dtn01.nersc.gov/project/projectdirs/m2015/atlasdatadisk/rucio/mc16_13TeV/3b/cd/log.11350637._033145.job.log.tgz.1'] vs [u'gsiftp://dtn01.nersc.gov:2811/project/projectdirs/m2015/atlasdatadisk/rucio/mc16_13TeV/3b/cd/log.11350637._033145.job.log.tgz.1'] ([

{'scope': u'mc16_13TeV', 'name': u'log.11350637._033145.job.log.tgz.1'}
])"]
```

In this message it does not make it clear, which path we should be editing vs which one Rucio is expected. I found the message sitting in 
rucio/src/lib/rucio/core/replica.py
around line 1023:
raise exception.InvalidPath('One of the PFNs provided does not match the Rucio expected PFN : %s vs %s (%s)' % (str(pfns), str(expected_pfns), str(lfns)))

So I see the first is probably what we set in AGIS and the second is what you are expecting. Can you make this clear in the error message?

Thanks,
Taylor

_Migrated from [JIRA](https://its.cern.ch/jira/browse/RUCIO-2692)_


Discussion:

Resolving patch:
diff --git a/lib/rucio/core/replica.py b/lib/rucio/core/replica.py
--- a/lib/rucio/core/replica.py
+++ b/lib/rucio/core/replica.py
@@ -1254,8 +1254,8 @@ def add_replicas(rse, files, account, rse_id=None, ignore_availability=True,
             expected_pfns = clean_surls(expected_pfns.values())
             pfns = clean_surls(pfns)
             if pfns != expected_pfns:
-                print('ALERT: One of the PFNs provided does not match the Rucio expected PFN : %s vs %s (%s)' % (str(pfns), str(expected_pfns), str(lfns)))
-                raise exception.InvalidPath('One of the PFNs provided does not match the Rucio expected PFN : %s vs %s (%s)' % (str(pfns), str(expected_pfns), str(lfns)))
+                print('ALERT: One of the PFNs provided does not match the Rucio expected PFN : got %s, expected %s (%s)' % (str(pfns), str(expected_pfns), str(lfns)))
+                raise exception.InvalidPath('One of the PFNs provided does not match the Rucio expected PFN : got %s, expected %s (%s)' % (str(pfns), str(expected_pfns), str(lfns)))
 
     nbfiles, bytes = __bulk_add_replicas(rse_id=replica_rse.id, files=files, account=account, session=session)
     increase(rse_id=replica_rse.id, files=nbfiles, bytes=bytes, session=session)
diff --git a/lib/rucio/web/ui/common/utils.py b/lib/rucio/web/ui/common/utils.py
--- a/lib/rucio/web/ui/common/utils.py
+++ b/lib/rucio/web/ui/common/utils.py
@@ -40,7 +40,7 @@ def get_token():
         token = authentication.get_auth_token_x509(account,
                                                    dn,
                                                    'webui',
-                                                   ctx.env.get('REMOTE_ADDR'))
+                                                   ctx.env.get('REMOTE_ADDR')).token
         return token
     except:
         return False
@@ -94,7 +94,7 @@ def check_token(rendered_tpl):
                 token = authentication.get_auth_token_x509(ui_account,
                                                            dn,
                                                            'webui',
-                                                           ctx.env.get('REMOTE_ADDR'))
+                                                           ctx.env.get('REMOTE_ADDR')).token
             except:
                 return render.problem(msg)
 
@@ -126,7 +126,7 @@ def check_token(rendered_tpl):
                 token = authentication.get_auth_token_x509(def_account,
                                                            dn,
                                                            'webui',
-                                                           ctx.env.get('REMOTE_ADDR'))
+                                                           ctx.env.get('REMOTE_ADDR')).token
             except:
                 return render.problem(msg)
 


Test patch: