Index: /trunk/pstamp/scripts/pstampparse.pl
===================================================================
--- /trunk/pstamp/scripts/pstampparse.pl	(revision 25051)
+++ /trunk/pstamp/scripts/pstampparse.pl	(revision 25052)
@@ -161,5 +161,4 @@
     
     die "job_type is list_uri but mode is $mode" if ($job_type eq "list_uri") and ($mode ne "list_uri");
-
 
     # note: resolve_project avoids running pstamptool every time by remembering the
@@ -202,5 +201,4 @@
     if (!$imageList or !@$imageList) {
         print STDERR "no matching images found for row $rownum\n";
-        next;
     }
     $row->{need_magic} = $need_magic;
@@ -269,8 +267,13 @@
         }
 
+        $job_num++;
+
         my $imagefile = $image->{image};
         if (($stage ne "stack") and ($need_magic and !$image->{magicked})) {
             # XXX: should we add a faulted job so the client can know what happened?
-            print STDERR "skippping non-magicked image $imagefile\n" if $verbose;
+            # print STDERR "skippping non-magicked image $imagefile\n" if $verbose;
+
+            insertFakeJobForRow($row, $job_num, 43);
+
             next;
         }
@@ -281,6 +284,4 @@
             $args .= " -class_id $component" if $component;
         }
-
-        $job_num++;
 
         # add astrometry file for raw and chip images if one is available
@@ -360,4 +361,13 @@
         die "get_image jobs not implemented yet";
     } else {
+        if (!$imageList or (scalar @$imageList eq 0)) {
+            # we didn't find any images for this set of rows. Insert a fake job to carry
+            # the status back to the requestor
+            foreach my $row (@$rowList) {
+                insertFakeJobForRow($row, 1, 42);
+                $num_jobs++;
+            }
+            return $num_jobs;
+        }
         my $thisRun;
 
@@ -423,4 +433,34 @@
     return $num_jobs;
 }
+sub insertFakeJobForRow
+{
+    my $row = shift;
+    my $job_num = shift;
+    my $fault = shift;
+
+    my $command = "$pstamptool -addjob  -req_id $req_id -job_type $row->{JOB_TYPE}"
+                        . " -rownum $row->{ROWNUM} -state stop -fault $fault";
+    $command .= " -dbname $dbname" if $dbname;
+    $command .= " -dbserver $dbserver" if $dbserver;
+
+    if ($mode eq "list_job") { 
+        # this is a debugging mode, just print the pstamptool that would have run
+        # this is sort of like the mode -noupdate that some other tools support
+        print "$command\n";
+    } elsif (!$no_update) {
+        # mode eq "queue_job"
+        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+            run(command => $command, verbose => $verbose);
+        unless ($success) {
+            print STDERR @$stderr_buf;
+            # XXX TODO: now what? Should we mark the error state for the request?
+            # should we keep going for other uris? If so how do we report that some
+            # of the work that the request wanted isn't going to get done
+            die "failed to queue job for request $req_id";
+        }
+    } else {
+        print "skipping command: $command\n";
+    }
+}
 
 sub get_run_id
