marc export exports all records when using an empty list of record IDs

Bug #1329872 reported by Robert Soulliere
14
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Evergreen
Fix Committed
Medium
Unassigned
3.11
Fix Released
Medium
Unassigned
3.12
Fix Released
Undecided
Unassigned

Bug Description

EG version 2.6
OpenSRF Version: 2.3
PostgreSQL Version: 9.1
Linux Distribution: Debian Squeeze

If trying to export records using the marc records export tool, all records will be exported if the file of IDs is empty.

For example:

In this case:
cat bibs.ids | /openils/bin/marc_export -f USMARC -e UTF-8 > records.marc

Records.marc will be all the records in the system if bibs.ids does not contain any record IDs.

tags: added: cat-importexport
Changed in evergreen:
status: New → Confirmed
Revision history for this message
Josh Stompro (u-launchpad-stompro-org) wrote :

I can confirm that this can be a problem and is still a problem in 3.3 - 3.11.

If I setup a process to generate a list of bibs the differ from the last export to feed into the script, but I don't check to make sure that the list isn't empty then I'll accidentally send an --all dump.

It seems like --all and --pipe are just to validate other arguments, they are not used to see if ids haven't been passed.

The code that looks like it checks for ids, doesn't validate that zero IDs haven't been passed. Or that ctrl+d hasn't just been pressed.

# Look for passed in ids:
my @ids = ();
if ($config->need_ids()) {
    print STDERR "Waiting for input\n" if (-t);
    while (my $i = <>) {
        push @ids, $i if ($i =~ /^\s*[0-9]+\s*$/);
    }
}

There needs to be second check after that, to error out if no IDs were passed. Like.

die "IDs required but not entered, exiting\n" if ($config->need_ids() && !@ids);

Before that change, these commands give the same result.

echo bob | marc_export
and
marc_export --all
and
echo bob | marc_export --pipe

After
$ echo bob | marc_export
IDs required but not entered, exiting

$ echo bob | marc_export --pipe
IDs required but not entered, exiting

Josh

Revision history for this message
Josh Stompro (u-launchpad-stompro-org) wrote :

Working branch at: user/stompro/lp1329872-marc_export-empty-ids-check

https://git.evergreen-ils.org/?p=working/Evergreen.git;a=shortlog;h=refs/heads/user/stompro/lp1329872-marc_export-empty-ids-check

Testing notes included in commit.

Josh

tags: added: pullrequest
Changed in evergreen:
assignee: nobody → Chris Sharp (chrissharp123)
Revision history for this message
Chris Sharp (chrissharp123) wrote :

Works as advertised. Pushed to master, rel_3_12 and rel_3_11. Thanks, Josh!

Changed in evergreen:
status: Confirmed → Fix Committed
importance: Undecided → Medium
assignee: Chris Sharp (chrissharp123) → nobody
milestone: none → 3.13-beta
milestone: 3.13-beta → 3.12.3
milestone: 3.12.3 → 3.13-beta
tags: added: signedoff
Revision history for this message
Andrea Neiman (aneiman) wrote :

Adding 3_11 LP target.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.