Skip to content

Commit

Permalink
add dataset existence validation for uploadContentRequest (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
myhau authored Jul 12, 2024
1 parent ca5c018 commit ea0d66a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion server/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,10 +403,13 @@ func (h *uploadContentHandler) Handle(ctx context.Context, r *uploadContentReque
load := r.job.Content().Configuration.Load
tableRef := load.DestinationTable
dataset := r.project.Dataset(tableRef.DatasetId)
if dataset == nil {
return fmt.Errorf("dataset `%s` is not found", tableRef.DatasetId)
}
table := dataset.Table(tableRef.TableId)
if table == nil {
if load.CreateDisposition == "CREATE_NEVER" {
return fmt.Errorf("`%s` is not found", tableRef.TableId)
return fmt.Errorf("table `%s` is not found", tableRef.TableId)
}
if _, err := (&tablesInsertHandler{}).Handle(ctx, &tablesInsertRequest{
server: r.server,
Expand Down

0 comments on commit ea0d66a

Please sign in to comment.