golang/go · error

no exit code (in %q)

Error message

no exit code (in %q)

What it means

Returned by exitCodeFilter.Finish (main.go:276) when the buffered adb output did not contain a full match of the exit-code regex (the captured group was absent). go_android_exec parses the test binary's exit code out of adb stdout via a regex; if the process produced no recognizable 'exit status N' marker, the wrapper cannot determine the result.

Source

Thrown at misc/go_android_exec/main.go:276

		if err != nil {
			return n, err
		}
	}
	return n, nil
}

func (f *exitCodeFilter) Finish() (int, error) {
	// f.buf could be empty, contain a partial match of exitRe, or
	// contain a full match.
	b := f.buf.Bytes()
	defer f.buf.Reset()
	match := f.exitRe.FindSubmatch(b)
	if len(match) < 2 || match[1] == nil {
		// Not a full match. Flush.
		if _, err := f.w.Write(b); err != nil {
			return 0, err
		}
		return 0, fmt.Errorf("no exit code (in %q)", string(b))
	}

	// Parse the exit code.
	code, err := strconv.Atoi(string(match[1]))
	if err != nil {
		// Something is malformed. Flush.
		if _, err := f.w.Write(b); err != nil {
			return 0, err
		}
		return 0, fmt.Errorf("bad exit code: %v (in %q)", err, string(b))
	}
	return code, nil
}

// pkgPath determines the package import path of the current working directory,
// and indicates whether it is
// and returns the path to the package source relative to $GOROOT (or $GOPATH).
func pkgPath() (importPath string, isStd bool, modPath, modDir string, err error) {

View on GitHub (pinned to b6b368adc5)

Solutions

  1. Inspect the flushed output quoted in the error message — it is the raw trailing stdout from the device and usually contains the crash reason.
  2. Run the binary directly via `adb exec-out` to reproduce and capture full output.
  3. Check logcat (`adb logcat`) for native crashes / OOM kills of the test process.
  4. Ensure the binary actually reaches normal exit; if it is killed, fix the underlying crash.
Defensive patterns

Strategy: try-catch

Try / catch

code, err := run.onDevice(...)
if err != nil {
    // err.Error() contains the raw flushed stdout — inspect it for crash cause.
    log.Printf("device run failed, tail output: %v", err)
    return err
}

Prevention

When it happens

Trigger: The wrapped binary crashed before printing the exit marker, was killed (SIGKILL/OOM), or the device/adb truncated output so the marker line never arrived. Also if a custom binary does not emit the expected exit-code line format.

Common situations: Test binary crashed early (nil-pointer, native panic) and printed no exit marker; device ran out of memory and killed the process; adb exec-out stream was interrupted; running a non-Go-test binary through go_android_exec.

Related errors


AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12). Data as JSON: /api/errors/c6e7fd70e07882a3. Report an issue: GitHub.