inveniosoftware / invenio

Invenio digital library framework
https://invenio.readthedocs.io
MIT License
620 stars 291 forks source link

Bug in BibUpload/BibRecord in record_modify_subfield() #1346

Open kaplun opened 10 years ago

kaplun commented 10 years ago

Originally on 2013-03-05

Somehow there is a bug around the usage of record_modify_subfield() in bibrecord:

* 2013-01-21 10:37:40 -> InvenioBibRecordFieldError: There is no subfield with position '3'. (bibrecord.py:694:record_modify_subfield)
[...]
  File "/usr/lib64/python2.4/site-packages/invenio/bibedit_engine.py", line 998, in perform_request_update_record
    field_position_local=field_position_local)
  File "/usr/lib64/python2.4/site-packages/invenio/bibrecord.py", line 694, in record_modify_subfield
    raise InvenioBibRecordFieldError("There is no subfield with position "
InvenioBibRecordFieldError: There is no subfield with position '3'.
[...]
** Stack frame details

Frame record_modify_subfield in /usr/lib64/python2.4/site-packages/invenio/bibrecord.py at line 694
-------------------------------------------------------------------------------
       691     try:
       692         subfields[subfield_position] = (subfield_code, value)
       693     except IndexError:
---->  694         raise InvenioBibRecordFieldError("There is no subfield with position "
       695             "'%d'." % subfield_position)
       696 
       697 def record_move_subfield(rec, tag, subfield_position, new_subfield_position,
-------------------------------------------------------------------------------
        field_position_local =  '29'
               subfield_code =  "'u'"
        field_position_global =  'None'
                       value =  "'UC, Davis'"
                         tag =  "'700'"
                         rec =  "{'595': [([('a', 'LANL EDS')], ' ', ' ', *, 4)], '980': [([('a', 'ARTICLE')], ' ', ' ', *, 5)], '700': [([('a', 'Frixione, Stefano'), ('e', 'convenor and ed.'), ('u', 'INFN Genoa')], ' ', ' ', *, 7), ([('a', 'Bedjidian, Marc'), ('e', 'convenor'), ('u', 'INP Lyon')], ' ', ' ', *, 9), ([('a', 'Blaschke, D')], ' ', ' ', *, 11), ([('a', 'Bodwin, G T')], ' ', ' ', *, 13), ([('a', 'Carrer, N'), ('u', 'CERN')], ' ', ' ', *, 15), ([('a', 'Cole, B')], ' ', ' ', *, 17), ([('a', 'Crochet, Philippe [...]
           subfield_position =  '3'
                   subfields =  "[('a', 'Marchal, N')]"

Frame perform_request_update_record in /usr/lib64/python2.4/site-packages/invenio/bibedit_engine.py at line 998
-------------------------------------------------------------------------------
       995                 record_modify_subfield(record, data['tag'],
       996                     data['subfieldCode'], data['value'],
       997                     int(data['subfieldIndex']),
---->  998                     field_position_local=field_position_local)
       999             else:
      1000                 record_modify_controlfield(record, data['tag'], data["value"],
      1001                   field_position_local=field_position_local)
-------------------------------------------------------------------------------
                   undo_list =  "[{'operation_type': 'move_field', 'direction': 'down', 'tag': '700', 'field_position': 0}, {'operation_type': 'move_field', 'direction': 'down', 'tag': '700', 'field_position': 1}, {'operation_type': 'move_field', 'direction': 'down', 'tag': '700', 'field_position': 2}, {'operation_type': 'move_field', 'direction': 'down', 'tag': '700', 'field_position': 3}, {'operation_type': 'move_field', 'direction': 'down', 'tag': '700', 'field_position': 4}, {'operation_type': 'move_field', 'direction': 'd [...]
             pending_changes =  '[]'
        field_position_local =  '29'
                request_type =  "'modifyContent'"
                         uid =  '15166'
             record_revision =  '(2013, 1, 21, 10, 17, 57, 0, 21, -1)'
                      record =  "{'595': [([('a', 'LANL EDS')], ' ', ' ', *, 4)], '980': [([('a', 'ARTICLE')], ' ', ' ', *, 5)], '700': [([('a', 'Frixione, Stefano'), ('e', 'convenor and ed.'), ('u', 'INFN Genoa')], ' ', ' ', *, 7), ([('a', 'Bedjidian, Marc'), ('e', 'convenor'), ('u', 'INP Lyon')], ' ', ' ', *, 9), ([('a', 'Blaschke, D')], ' ', ' ', *, 11), ([('a', 'Bodwin, G T')], ' ', ' ', *, 13), ([('a', 'Carrer, N'), ('u', 'CERN')], ' ', ' ', *, 15), ([('a', 'Cole, B')], ' ', ' ', *, 17), ([('a', 'Crochet, Philippe [...]
                   redo_list =  '[]'
                       recid =  '815044'
                  cacheMTime =  '1358761019'
                  undoRedoOp =  "{'oldCode': 'u', 'newVal': 'UC, Davis', 'oldVal': 'UC Davis', 'tag': '700', 'newCode': 'u', 'operation_type': 'change_content', 'fieldPos': '29', 'subfieldPos': '3'}"
        deactivated_hp_changes =  '{}'
                      isBulk =  'False'
                   hpChanges =  '{}'
                        data =  "{'subfieldCode': 'u', 'requestType': 'modifyContent', 'value': 'UC, Davis', 'fieldPosition': '29', 'undoRedo': {'oldCode': 'u', 'newVal': 'UC, Davis', 'oldVal': 'UC Davis', 'tag': '700', 'newCode': 'u', 'operation_type': 'change_content', 'fieldPos': '29', 'subfieldPos': '3'}, 'tag': '700', 'recID': 815044, 'cacheMTime': 1358761019, 'subfieldIndex': '3', 'ID': 87}"
                    response =  '{}'
[...]

Another case is:

Traceback (most recent call last):
   File "/usr/lib64/python2.4/site-packages/invenio/bibupload.py", line 350, in bibupload
     record = synchronize_8564(rec_id, record, record_had_FFT, pretend=pretend)
   File "/usr/lib64/python2.4/site-packages/invenio/bibupload.py", line 1100, in synchronize_8564
     merge_bibdocfile_into_marc(field, tags8564s_to_add[url])
   File "/usr/lib64/python2.4/site-packages/invenio/bibupload.py", line 1038, in merge_bibdocfile_into_marc
     subfield_position, field_position_global=field[4])
   File "/usr/lib64/python2.4/site-packages/invenio/bibrecord.py", line 694, in record_modify_subfield
     raise InvenioBibRecordFieldError("There is no subfield with position "
InvenioBibRecordFieldError: There is no subfield with position '1'.
[...]
** Stack frame details

Frame record_modify_subfield in 
/usr/lib64/python2.4/site-packages/invenio/bibrecord.py at line 694
-------------------------------------------------------------------------------
        691     try:
        692         subfields[subfield_position] = (subfield_code, value)
        693     except IndexError:
---->  694         raise InvenioBibRecordFieldError("There is no 
subfield with position "
        695             "'%d'." % subfield_position)
        696
        697 def record_move_subfield(rec, tag, subfield_position, 
new_subfield_position,
-------------------------------------------------------------------------------
        field_position_local =  'None'
               subfield_code =  "'y'"
        field_position_global =  '-1'
                       value =  "'00000 The Signal-to-Foreground spectrum for 
all $m$-modes. We have plotted $\\\\log_{10} \\\\lambda_{i m}$, where 
for each $m$ the eigenvalues have been sorted by in ascending order 
(thus there is no physical interpretation to the vertical direction). 
The contours are drawn at $-4$, $-2$, $0$, $2$ and $4$.'"
                         tag =  "'856'"
                         rec =  "{'856': [([('u', 
'http://inspirehep.net/record/1217472/files/evals.png')], '4', ' ', '', 
-1), ([('u', 'http://inspirehep.net/record/1217472/files/evals.png'), 
('y', '00000 The Signal-to-Foreground spectrum for all $m$-modes. We 
have plotted $\\\\log_{10} \\\\lambda_{i m}$, where for each $m$ the 
eigenvalues have been sorted by in ascending order (thus there is no 
physical interpretation to the vertical direction). The contours are 
drawn at $-4$, $-2$, $0$, $2$ and $4$.')], '4', ' ', '', -1), ([ [...]
           subfield_position =  '1'
                   subfields =  "[('u', 
'http://inspirehep.net/record/1217472/files/evals.png')]"

Frame merge_bibdocfile_into_marc in 
/usr/lib64/python2.4/site-packages/invenio/bibupload.py at line 1038
-------------------------------------------------------------------------------
       1035             if code in subfields:
       1036                 ## ...We substitute it with what is in 
BibDocFile tables
       1037                 record_modify_subfield(record, '856', code, 
subfields[code],
----> 1038                     subfield_position, 
field_position_global=field[4])
       1039                 del subfields[code]
       1040             else:
       1041                 ## ...We delete it otherwise
-------------------------------------------------------------------------------
                        code =  "'y'"
                      record =  "{'856': [([('u', 
'http://inspirehep.net/record/1217472/files/evals.png')], '4', ' ', '', 
-1), ([('u', 'http://inspirehep.net/record/1217472/files/evals.png'), 
('y', '00000 The Signal-to-Foreground spectrum for all $m$-modes. We 
have plotted $\\\\log_{10} \\\\lambda_{i m}$, where for each $m$ the 
eigenvalues have been sorted by in ascending order (thus there is no 
physical interpretation to the vertical direction). The contours are 
drawn at $-4$, $-2$, $0$, $2$ and $4$.')], '4', ' ', '', -1), ([ [...]
                       value =  "'00000 The Signal-to-Foreground spectrum for 
all $m$-modes. We have plotted $\\\\log_{10} \\\\lambda_{i m}$, where 
for each $m$ the eigenvalues have been sorted by in ascending order 
(thus there is no physical interpretation to the vertical direction). 
The contours are drawn at $-4$, $-2$, $0$, $2$ and $4$.'"
                       field =  "([('u', 
'http://inspirehep.net/record/1217472/files/evals.png'), ('y', '00000 
The Signal-to-Foreground spectrum for all $m$-modes. We have plotted 
$\\\\log_{10} \\\\lambda_{i m}$, where for each $m$ the eigenvalues have 
been sorted by in ascending order (thus there is no physical 
interpretation to the vertical direction). The contours are drawn at 
$-4$, $-2$, $0$, $2$ and $4$.')], '4', ' ', '', -1)"
           subfield_position =  '1'
          subfield_to_delete =  '[]'
                   subfields =  "{'y': '00000 The Signal-to-Foreground spectrum 
for all $m$-modes. We have plotted $\\\\log_{10} \\\\lambda_{i m}$, 
where for each $m$ the eigenvalues have been sorted by in ascending 
order (thus there is no physical interpretation to the vertical 
direction). The contours are drawn at $-4$, $-2$, $0$, $2$ and $4$.'}"

Frame synchronize_8564 in 
/usr/lib64/python2.4/site-packages/invenio/bibupload.py at line 1100
-------------------------------------------------------------------------------
       1097             for url in field_get_subfield_values(field, 'u') 
+ field_get_subfield_values(field, 'q'):
       1098                 if url in tags8564s_to_add:
       1099                     if record_had_FFT:
----> 1100                         merge_bibdocfile_into_marc(field, 
tags8564s_to_add[url])
       1101                     else:
       1102                         merge_marc_into_bibdocfile(field, 
pretend=pretend)
       1103                     del tags8564s_to_add[url]
-------------------------------------------------------------------------------
            tags8564s_to_add = 
"{'http://inspirehep.net/record/1217472/files/sg_kl_10_map.png': {'y': 
'00006 This plot illustrates the foreground removal process in action on 
simulations of the foregrounds-only (top row) and signal-only (bottom 
row). Each plot has two elements, an image of the 
\\\\SI{400}{\\\\mega\\\\hertz} frequency slice on top, and beneath, a 
cut through the celestial equator (from $270$--$300$ degrees) showing 
the frequency axis. The left-most column shows the original simulations 
on the sky. The band app [...]
        merge_bibdocfile_into_marc =  '<function merge_bibdocfile_into_marc at 
0x2aaad826daa0>'
                      record =  "{'856': [([('u', 
'http://inspirehep.net/record/1217472/files/evals.png')], '4', ' ', '', 
-1), ([('u', 'http://inspirehep.net/record/1217472/files/evals.png'), 
('y', '00000 The Signal-to-Foreground spectrum for all $m$-modes. We 
have plotted $\\\\log_{10} \\\\lambda_{i m}$, where for each $m$ the 
eigenvalues have been sorted by in ascending order (thus there is no 
physical interpretation to the vertical direction). The contours are 
drawn at $-4$, $-2$, $0$, $2$ and $4$.')], '4', ' ', '', -1), ([ [...]
                         url = 
"'http://inspirehep.net/record/1217472/files/evals.png'"
        positions_tags8564s_to_remove =  '[]'
                     pretend =  'True'
              local_position =  '1'
                      rec_id =  '1217472'
              record_had_FFT =  'True'
                       field =  "([('u', 
'http://inspirehep.net/record/1217472/files/evals.png'), ('y', '00000 
The Signal-to-Foreground spectrum for all $m$-modes. We have plotted 
$\\\\log_{10} \\\\lambda_{i m}$, where for each $m$ the eigenvalues have 
been sorted by in ascending order (thus there is no physical 
interpretation to the vertical direction). The contours are drawn at 
$-4$, $-2$, $0$, $2$ and $4$.')], '4', ' ', '', -1)"
                    tags856s =  "[([('u', 
'http://inspirehep.net/record/1217472/files/evals.png')], '4', ' ', '', 
-1), ([('u', 'http://inspirehep.net/record/1217472/files/evals.png'), 
('y', '00000 The Signal-to-Foreground spectrum for all $m$-modes. We 
have plotted $\\\\log_{10} \\\\lambda_{i m}$, where for each $m$ the 
eigenvalues have been sorted by in ascending order (thus there is no 
physical interpretation to the vertical direction). The contours are 
drawn at $-4$, $-2$, $0$, $2$ and $4$.')], '4', ' ', '', -1), ([('u', 'h 
[...]
        merge_marc_into_bibdocfile =  '<function merge_marc_into_bibdocfile at 
0x2aaad826d938>'
        get_bibdocfile_managed_info =  '<function get_bibdocfile_managed_info 
at 0x2aaae3d31c80>'

Frame bibupload in 
/usr/lib64/python2.4/site-packages/invenio/bibupload.py at line 352
-------------------------------------------------------------------------------
        349             try:
        350                 record = synchronize_8564(rec_id, record, 
record_had_FFT, pretend=pretend)
        351             except Exception, e:
---->  352                 register_exception(alert_admin=True)
        353                 msg = "   Stage 2B failed: Error while 
synchronizing 8564 tags: %s" % e
        354                 write_message(msg, verbose=1, stream=sys.stderr)
        355                 return (1, int(rec_id), msg)
-------------------------------------------------------------------------------
        record_had_altered_bit =  '[]'
                     pretend =  'True'
                           e = 
'<invenio.bibrecord_config.InvenioBibRecordFieldError instance at 
0x2aaae104b128>'
        opt_stage_to_start_from =  '1'
            record_deleted_p =  'True'
                     opt_tag =  'None'
                     rec_old =  "{'856': [([('u', 
'http://inspirehep.net/record/1217472/files/arXiv%3A1302.0327.pdf')], 
'4', ' ', '', 10), ([('u', 
'http://inspirehep.net/record/1217472/files/evals.png'), ('y', '00000 
The Signal-to-Foreground spectrum for all $m$-modes. We have plotted 
$\\\\log_{10} \\\\lambda_{i m}$, where for each $m$ the eigenvalues have 
been sorted by in ascending order (thus there is no physical 
interpretation to the vertical direction). The contours are drawn at 
$-4$, $-2$, $0$, $2$ and $4$.')], '4', ' ', [...]
                      rec_id =  '1217472'
              record_had_FFT =  'True'
          we_have_fmt_tags_p =  'False'
                  oai_rec_id =  "''"
            opt_notimechange =  '0'
               insert_mode_p =  'False'
                       error =  'None'
             original_record =  "{'856': [([('u', 
'http://inspirehep.net/record/1217472/files/arXiv%3A1302.0327.pdf')], 
'4', ' ', '', 10), ([('u', 
'http://inspirehep.net/record/1217472/files/evals.png'), ('y', '00000 
The Signal-to-Foreground spectrum for all $m$-modes. We have plotted 
$\\\\log_{10} \\\\lambda_{i m}$, where for each $m$ the eigenvalues have 
been sorted by in ascending order (thus there is no physical 
interpretation to the vertical direction). The contours are drawn at 
$-4$, $-2$, $0$, $2$ and $4$.')], '4', ' ', [...]
                 has_bibdocs =  'True'
                         now =  'datetime.datetime(2013, 3, 4, 21, 40, 57, 172469)'
                    opt_mode =  "'replace'"
                      record =  "{'856': [([('u', 
'http://inspirehep.net/record/1217472/files/evals.png')], '4', ' ', '', 
-1), ([('u', 'http://inspirehep.net/record/1217472/files/evals.png'), 
('y', '00000 The Signal-to-Foreground spectrum for all $m$-modes. We 
have plotted $\\\\log_{10} \\\\lambda_{i m}$, where for each $m$ the 
eigenvalues have been sorted by in ascending order (thus there is no 
physical interpretation to the vertical direction). The contours are 
drawn at $-4$, $-2$, $0$, $2$ and $4$.')], '4', ' ', '', -1), ([ [...]
tiborsimko commented 8 years ago

@kaplun Do you know whether this is still the case?

kaplun commented 8 years ago

Indeed it is still the case, at least in INSPIRE (just checked our sentry). Albeit the error is not so common.

kaplun commented 7 years ago

@tsgit have you noticed this error lately? Or since it's so rare we can ignore it for good?

tsgit commented 7 years ago

I see similar errors a few times each month

* 2016-12-02 21:15:01 -> InvenioBibRecordFieldError: There is no subfield with position '7'. (bibrecord.py:803:record_modify_subfield) or * 2016-06-24 11:22:54 -> InvenioBibRecordFieldError: No field has the tag '653' and the local field position '3'. (bibrecord.py:684:record_get_field)

they happen in various code locations/functions T.