Skip to content

Commit

Permalink
fix: unhandled parse BQ table FQN (#42)
Browse files Browse the repository at this point in the history
Handle panic error due to invalid fqn
  • Loading branch information
haveiss authored Nov 15, 2023
1 parent 7e91ad5 commit 03d709b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions plugins/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,10 @@ func parseBQTableFQN(fqn string) (projectID, datasetID, tableID string, err erro
ss := strings.FieldsFunc(fqn, func(r rune) bool {
return r == ':' || r == '.'
})
if len(ss) < 3 {
return "", "", "", fmt.Errorf(
"unexpected BigQuery table FQN '%s', expected in format projectID:datasetID.tableID", fqn,
)
}
return ss[0], ss[1], ss[2], nil
}
5 changes: 5 additions & 0 deletions plugins/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ func TestBigQueryTableFQNToURN(t *testing.T) {
fqn: "bq-raw-internal:dagstream_production_feast09_s2id13_30min_demand",
expectedErr: "map URN: unexpected BigQuery table FQN 'bq-raw-internal:dagstream_production_feast09_s2id13_30min_demand', expected in format",
},
{
name: "Invalid",
fqn: ":.",
expectedErr: "map URN: unexpected BigQuery table FQN ':.', expected in format",
},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
Expand Down

0 comments on commit 03d709b

Please sign in to comment.