redpanda-data / redpanda-data/connect

bloblang: hostname() errors without Benthos

Open
#1,291 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bloblang documentation enhancement ux
Dominant language
Go
Stars
8.8k
Forks
969
Avg merge
1d 13h
Merged PRs (30d)
64

Description

I'm looking at using bloblang in another app. The only issue I've found so far is that hostname doesn't seem to work.

package main

import (
	"encoding/json"
	"fmt"
	"log"

	"github.com/benthosdev/benthos/v4/public/bloblang"
)

func main() {
	mapping := `
		root.host = hostname()
		root.ksuid = ksuid()
	`
	exe, err := bloblang.Parse(mapping)
	if err != nil {
		log.Fatal(err)
	}
	src := "{}"
	var object interface{}
	err = json.Unmarshal([]byte(src), &object)
	if err != nil {
		log.Fatal(err)
	}
	res, err := exe.Query(object)
	if err != nil {
		log.Fatal(err)
	}
	jsonBytes, err := json.MarshalIndent(res, "", "  ")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(string(jsonBytes))
}

The output is below. If you comment out hostname, then ksuid works just fine.

2022/06/14 08:56:46 unrecognised function 'hostname': hostn
exit status 1

Bloblang is fantastic! This is a great little scripting tool and works really well for what you're doing -- and hopefully what I'm doing. My only other concern is that it pulls A LOT of dependencies into my application when I include it.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the public/bloblang package and reproduce the standalone example using bloblang.Parse and exe.Query. Trace how hostname and ksuid are registered when Bloblang runs outside Benthos; done means the example resolves hostname successfully without Benthos while ksuid continues to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
stream-processing, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.