Skip to content

Commit

Permalink
Merge pull request #69 from nyaruka/run_error_tweak
Browse files Browse the repository at this point in the history
Don't log entire run JSON on error, just UUID
  • Loading branch information
rowanseymour authored Jun 13, 2022
2 parents d0b5832 + 2876953 commit bda56e9
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions archives/runs.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const (
)

const lookupFlowRuns = `
SELECT rec.exited_on, row_to_json(rec)
SELECT rec.uuid, rec.exited_on, row_to_json(rec)
FROM (
SELECT
fr.id as id,
Expand Down Expand Up @@ -70,20 +70,23 @@ func writeRunRecords(ctx context.Context, db *sqlx.DB, archive *Archive, writer
defer rows.Close()

recordCount := 0

var runUUID string
var runExitedOn *time.Time
var record string
var exitedOn *time.Time
for rows.Next() {
err = rows.Scan(&exitedOn, &record)

// shouldn't be archiving an active run, that's an error
if exitedOn == nil {
return 0, fmt.Errorf("run still active, cannot archive: %s", record)
}
for rows.Next() {
err = rows.Scan(&runUUID, &runExitedOn, &record)

if err != nil {
return 0, errors.Wrapf(err, "error scanning run record for org: %d", archive.Org.ID)
}

// shouldn't be archiving an active run, that's an error
if runExitedOn == nil {
return 0, fmt.Errorf("run %s still active, cannot archive", runUUID)
}

writer.WriteString(record)
writer.WriteString("\n")
recordCount++
Expand Down

0 comments on commit bda56e9

Please sign in to comment.