wtfutil/wtf · warning

no table structure returned from query

Error message

no table structure returned from query

What it means

After RunQuery succeeds, fetchDataAsync validates the response: if the table response is nil or has no Header columns, it reports 'no table structure returned from query'. This guards against rendering an empty/malformed Log Analytics payload rather than an actual query failure.

Source

Thrown at modules/azurelogs/widget.go:79

/* -------------------- Helper Functions -------------------- */

func (widget *Widget) fetchDataAsync() {
	sess, err := Init(to.Ptr(widget.settings.Queryfile))
	if err != nil {
		widget.setError(fmt.Errorf("failed to initialize Azure session: %w", err))
		return
	}

	// Execute Azure query directly
	tableResp, err := RunQuery(sess)
	if err != nil {
		widget.setError(fmt.Errorf("failed to execute Azure query: %w", err))
		return
	}

	// Check if we have valid data structure
	if tableResp == nil || len(tableResp.Header) == 0 {
		widget.setError(fmt.Errorf("no table structure returned from query"))
		return
	}

	// Store the data and mark as loaded
	widget.tableData = tableResp
	widget.dataLoaded = true
	widget.loading = false
	widget.Redraw(widget.content)
}

// setError is a helper function to set error state and trigger redraw
func (widget *Widget) setError(err error) {
	widget.lastError = err
	widget.loading = false
	widget.Redraw(widget.content)
}

func (widget *Widget) renderTable(title string) (string, string, bool) {

View on GitHub (pinned to bb838c1ccb)

Solutions

  1. Verify the query returns at least one column (test in Azure portal Log Analytics)
  2. Check the queried table exists in the selected workspace and RBAC permits reading it
  3. Add a default column or '| project' clause so an empty result still has a schema

Example fix

// before
let q = "Heartbeat | where TimeGenerated > ago(1h) and Computer == 'nonexistent'"
// returns zero rows / degenerate table
// after
let q = "Heartbeat | where TimeGenerated > ago(1h) | project TimeGenerated, Computer | take 10"
// always yields a defined column set
Defensive patterns

Strategy: validation

Validate before calling

func hasTableStructure(t *TableResponse) bool {
    return t != nil && len(t.Header) > 0
}
if !hasTableStructure(tableResp) {
    widget.setError(errors.New("no table structure returned from query"))
    return
}

Type guard

func validTable(t *TableResponse) bool {
    return t != nil && len(t.Header) > 0
}

Try / catch

if !validTable(tableResp) {
    widget.setError(errors.New("no table structure returned from query"))
    return
}

Prevention

When it happens

Trigger: RunQuery returns a non-nil *tableResp whose Header slice is empty (len(tableResp.Header)==0), or returns nil with a nil error — e.g. the KQL query matched no data or returned a degenerate table.

Common situations: KQL query with zero matching rows producing an empty schema; restrictive RBAC returning empty results; Azure API changes or projection that drops all columns; querying a table that doesn't exist in the workspace.

Related errors


AI-assisted analysis of wtfutil/wtf@bb838c1ccb (2026-09-03). Data as JSON: /api/errors/4902481e6e6bf3c4. Report an issue: GitHub.