HarperFast / HarperFast/harper

Bun: empty Basic-auth credentials cause stack overflow instead of 401

Open
#696 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
89
Forks
10
Avg merge
2d 6h
Merged PRs (30d)
200

Description

## Summary

Sending a Basic-auth header with empty username and empty password (`Basic `) causes Harper to crash with `Maximum call stack size exceeded` under Bun instead of returning a graceful 401.

## Reproduction

Start Harper on Bun and send:

```
POST /
Authorization: Basic Og==
Content-Type: application/json

{"operation":"describe_all"}
```

## Observed

Harper throws a stack overflow and the worker becomes unresponsive:

```
{"error":"Maximum call stack size exceeded."}
```

## Expected

401 with `{"error":"Must login"}` or similar.

## Context

Discovered via integration test `describe_all with empty credentials returns 401` in `integrationTests/apiTests/authentication.test.mjs` (PR #645). The test was skipped on Bun as a workaround.

The crash only occurs on Bun. Node.js handles the same request correctly. The stack trace points into `dist/security/auth.js` — likely a recursive call triggered when both username and password are empty strings that behaves differently under Bun's string/prototype handling.

Related: #38 (Support running on Bun)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.