Tencent/WeKnora · error

failed to build docreader dial options: %w

Error message

failed to build docreader dial options: %w

What it means

GRPCDocumentReader.connect failed to build gRPC dial options from the docreader auth config (docclient.LoadAuthConfigFromEnv), e.g. invalid TLS material or credentials in environment variables. The connection is never attempted.

Source

Thrown at internal/infrastructure/docparser/grpc_parser.go:53

	client proto.DocReaderClient
	addr   string
}

func NewGRPCDocumentReader(addr string) (*GRPCDocumentReader, error) {
	p := &GRPCDocumentReader{}
	if addr != "" {
		if err := p.connect(addr); err != nil {
			return nil, err
		}
	}
	return p, nil
}

func (p *GRPCDocumentReader) connect(addr string) error {
	authConfig := docclient.LoadAuthConfigFromEnv()
	opts, err := authConfig.BuildDialOptions(getMaxMessageSize())
	if err != nil {
		return fmt.Errorf("failed to build docreader dial options: %w", err)
	}
	if authConfig.TLSEnabled {
		logger.Infof(context.Background(), "TLS enabled for docreader gRPC client")
	}
	if authConfig.AuthToken != "" {
		logger.Infof(context.Background(),
			"Token authentication enabled for docreader gRPC client (TLS=%v)",
			authConfig.TLSEnabled,
		)
	}

	resolver.SetDefaultScheme("dns")

	start := time.Now()
	conn, err := grpc.Dial("dns:///"+addr, opts...)
	if err != nil {
		return fmt.Errorf("failed to connect to docreader: %w", err)
	}

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Check docreader auth/TLS environment variables for validity
  2. Verify cert/key paths exist and are readable
  3. Fix the auth config and trigger Reconnect
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at internal/infrastructure/docparser/grpc_parser.go:53 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02). Data as JSON: /api/errors/2957b2bf044df469. Report an issue: GitHub.