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
Confirmed
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
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.