Skip to content

Disable rate limits in local dev#712

Merged
rickyrombo merged 4 commits intomainfrom
mjp-rate-limit-dev
Mar 11, 2026
Merged

Disable rate limits in local dev#712
rickyrombo merged 4 commits intomainfrom
mjp-rate-limit-dev

Conversation

@rickyrombo
Copy link
Contributor

No description provided.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates API server initialization to skip rate limiting (and currently also metrics collection) when running in a local development environment, based on config.Env.

Changes:

  • Introduces an isLocalDev environment check (dev / development) during server setup.
  • Prevents initialization of RateLimitMiddleware (and MetricsCollector) when isLocalDev is true.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI commented Mar 11, 2026

@rickyrombo I've opened a new pull request, #715, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Contributor

Copilot AI commented Mar 11, 2026

@rickyrombo I've opened a new pull request, #716, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 2 commits March 10, 2026 19:44
`isLocalDev` only checked for `"dev"` and `"development"`, but
`config/config.go` treats `ENV=""` identically (same switch
fallthrough). With `ENV` unset, rate limiting remained enabled despite
the local dev intent.

## Changes

- **`api/server.go`**: Add `config.Env == ""` to `isLocalDev` to match
`config.go` semantics:

```go
// Before
isLocalDev := config.Env == "dev" || config.Env == "development"

// After
isLocalDev := config.Env == "dev" || config.Env == "development" || config.Env == ""
```

<!-- START COPILOT CODING AGENT TIPS -->
---

✨ Let Copilot coding agent [set things up for
you](https://github.com/AudiusProject/api/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot)
— coding agent works faster and does higher quality work when set up for
your repo.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: rickyrombo <3690498+rickyrombo@users.noreply.github.com>
…dleware (#716)

The previous change mistakenly disabled both `metricsCollector` and
`rateLimitMiddleware` in local dev environments. Only rate limiting
should be skipped in local dev.

## Changes

- **`api/server.go`**: Split the single initialization guard into two
separate conditions:
- `metricsCollector` — gated on `writePool != nil && config.Env !=
"test"` (enabled in local dev)
- `rateLimitMiddleware` — additionally gated on `!isLocalDev` (disabled
in local dev)

```go
if writePool != nil && config.Env != "test" {
    metricsCollector = NewMetricsCollector(logger, writePool)
    if !isLocalDev {
        rateLimitMiddleware = NewRateLimitMiddleware(logger, writePool)
    }
}
```

<!-- START COPILOT CODING AGENT TIPS -->
---

💡 You can make Copilot smarter by setting up custom instructions,
customizing its development environment and configuring Model Context
Protocol (MCP) servers. Learn more [Copilot coding agent
tips](https://gh.io/copilot-coding-agent-tips) in the docs.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: rickyrombo <3690498+rickyrombo@users.noreply.github.com>
@rickyrombo rickyrombo merged commit bbba1cd into main Mar 11, 2026
4 checks passed
@rickyrombo rickyrombo deleted the mjp-rate-limit-dev branch March 11, 2026 06:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants