Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hydrate function not called when having two underscores #4490

Open
fabian-zeindl-oebb opened this issue Feb 17, 2025 · 1 comment
Open

hydrate function not called when having two underscores #4490

fabian-zeindl-oebb opened this issue Feb 17, 2025 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@fabian-zeindl-oebb
Copy link

fabian-zeindl-oebb commented Feb 17, 2025

Describe the bug
Writing a plugin with a custom hydrate functions, leads to the hydrate-function silently not being called if there are two underscores in the column-name. There is no error logged, I just found this via trial and error

Steampipe version (steampipe -v)
Example: v1.0.3

To reproduce

func myTable() *plugin.Table {
	return &plugin.Table{
		Name:        "my_table",
		Description: "",
		List: &plugin.ListConfig{
			Hydrate: hydrateList,
		},
		Columns: []*plugin.Column{
			{Name: "repository", Type: proto.ColumnType_STRING, Description: ""},
			{Name: "jenkinsfile_contents", Type: proto.ColumnType_JSON, Description: "", Hydrate: hydrateJenkinsfileContents}
		},
	}
}

type TableRepositoriesRow struct {
	Repository string
}

type HydrateJenkinsfileContentsRow struct {
	JenkinsfileContents string
}

func hydrateList(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (any, error) {
        row := TableRepositoriesRow{Repository: "test1"}
	d.StreamListItem(ctx, &row)

	return nil, nil
}

func hydrateJenkinsfileContents(ctx context.Context, _ *plugin.QueryData, h *plugin.HydrateData) (any, error) {
	// ...
	result := HydrateJenkinsfileContentsRow{JenkinsfileContents: "test2"}
	return result, nil
}

The sample above works, but steampipe is extremely picky about either the function name or the column name and silently swallows the error.
The columns just remains empty.

  • jenkinsfile_contents with HydrateJenkinsfileContentsRow{JenkinsfileContents: *content} works
  • jenkins_file_contents with HydrateJenkinsFileContentsRow{JenkinsFileContents: *content} does not work

Expected behavior
Log an error if the column-name does not match the hydrate-function/data instead of just not providing data.
Or make the matching algorithm handle multiple underscores.

@fabian-zeindl-oebb fabian-zeindl-oebb added the bug Something isn't working label Feb 17, 2025
@pskrbasu
Copy link
Contributor

@fabian-zeindl-oebb Thanks for raising the detailed issue, I will take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants