Skip to content

Commit

Permalink
fix: properly escape table name when querying for failed events (#2663)
Browse files Browse the repository at this point in the history
  • Loading branch information
atzoum authored Nov 7, 2022
1 parent a53657d commit 9c009d9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions router/failed-events-manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"database/sql"
"encoding/json"
"fmt"
"strings"
"time"

"github.com/rudderlabs/rudder-server/utils/misc"
Expand Down Expand Up @@ -55,7 +56,7 @@ func (*FailedEventsManagerT) SaveFailedRecordIDs(taskRunIDFailedEventsMap map[st
}

for taskRunID, failedEvents := range taskRunIDFailedEventsMap {
table := fmt.Sprintf(`%s_%s`, failedKeysTablePrefix, taskRunID)
table := `"` + strings.ReplaceAll(fmt.Sprintf(`%s_%s`, failedKeysTablePrefix, taskRunID), `"`, `""`) + `"`
sqlStatement := fmt.Sprintf(`CREATE TABLE IF NOT EXISTS %s (
destination_id TEXT NOT NULL,
record_id JSONB NOT NULL,
Expand Down Expand Up @@ -110,7 +111,7 @@ func (fem *FailedEventsManagerT) FetchFailedRecordIDs(taskRunID string) []*Faile

var rows *sql.Rows
var err error
table := fmt.Sprintf(`%s_%s`, failedKeysTablePrefix, taskRunID)
table := `"` + strings.ReplaceAll(fmt.Sprintf(`%s_%s`, failedKeysTablePrefix, taskRunID), `"`, `""`) + `"`
sqlStatement := fmt.Sprintf(`SELECT %[1]s.destination_id, %[1]s.record_id
FROM %[1]s `, table)
rows, err = fem.dbHandle.Query(sqlStatement)
Expand Down

0 comments on commit 9c009d9

Please sign in to comment.