Repository: next.js
Issue: Turbo Dev crashes with OG Image at certain paths
Labels: Turbopack

### Link to the code that reproduces this issue

https://github.com/wotschofsky/domain-digger/tree/turbo-repro

### To Reproduce

1. Start the application in development (next dev)
2. See process crash





### Current vs. Expected behavior

Currently, Next.js Dev crashes completely, when OG image file is at located at certain paths.
File `/app/lookup/[domain]/(dns)/opengraph-image.tsx` seems to be the culprit.

Tested scenarios:
* `/app/lookup/[domain]/(dns)/opengraph-image.tsx` ❌
* `/app/lookup/(dns)/opengraph-image.tsx` ❌
* `/app/lookup/[domain]/opengraph-image.tsx` ✅
* `/app/[domain]/(dns)/opengraph-image.tsx` ✅
* `/app/lookup/opengraph-image.tsx` ✅
* `/app/opengraph-image.tsx` ✅

✅ Works
❌ Crashes


### Provide environment information

```bash
Node.js v20.18.1

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.2.0: Fri Dec  6 19:01:59 PST 2024; root:xnu-11215.61.5~2/RELEASE_ARM64_T6000
  Available memory (MB): 32768
  Available CPU cores: 10
Binaries:
  Node: 20.18.1
  npm: 10.8.2
  Yarn: N/A
  pnpm: 9.15.0
Relevant Packages:
  next: 15.1.1-canary.17 // Latest available version is detected (15.1.1-canary.17).
  eslint-config-next: N/A
  react: 19.0.0
  react-dom: 19.0.0
  typescript: 5.7.2
Next.js Config:
  output: N/A
```


### Which area(s) are affected? (Select all that apply)

Turbopack

### Which stage(s) are affected? (Select all that apply)

next dev (local)

### Additional context

Console logs

```
> next dev --turbo

   ▲ Next.js 15.1.1-canary.17 (Turbopack)
   - Local:        http://localhost:3000
   - Network:      http://192.168.178.53:3000
   - Environments: .env.local

 ✓ Starting...
FATAL: An unexpected Turbopack error occurred. Please report the content of /var/folders/32/606grn711z92qgqzbyqfwg8w0000gn/T/next-panic-e35483a9cf5e5fb8118fb6b68f0435e0.log, along with a description of what you were doing when the error occurred, to https://github.com/vercel/next.js/issues/new
[Error [TurbopackInternalError]: A task panicked: range end index 6 out of range for slice of length 5

Debug info:
- Execution of get_entrypoints_with_issues failed
- Execution of Project::entrypoints failed
- Execution of AppProject::routes failed
- Execution of directory_tree_to_entrypoints_internal failed
- Execution of directory_tree_to_entrypoints_internal failed
- Execution of directory_tree_to_entrypoints_internal failed
- A task panicked: range end index 6 out of range for slice of length 5]
```

Log file
```
---------------------------
Panic: panicked at crates/next-core/src/next_app/metadata/mod.rs:278:11:
range end index 6 out of range for slice of length 5
Backtrace:    0: <unknown>
   1: <unknown>
   2: <unknown>
   3: <unknown>
   4: <unknown>
   5: <unknown>
   6: <unknown>
   7: <unknown>
   8: <unknown>
   9: <unknown>
  10: <unknown>
  11: <unknown>
  12: <unknown>
  13: <unknown>
  14: <unknown>
  15: <unknown>
  16: <unknown>
  17: <unknown>
  18: <unknown>
  19: <unknown>
  20: <unknown>
  21: <unknown>
  22: <unknown>
  23: <unknown>
  24: <unknown>
  25: <unknown>
  26: <unknown>
  27: <unknown>
  28: <unknown>
  29: <unknown>
  30: <unknown>
  31: <unknown>
  32: <unknown>
  33: <unknown>
  34: <unknown>
  35: <unknown>
  36: <unknown>
  37: <unknown>
  38: <unknown>
  39: __pthread_deallocate
```