Skip to content

fix(import): remove rate limit from chunk endpoints — closes #113 regression#119

Open
fabiodalez-dev wants to merge 2 commits intomainfrom
fix/import-chunk-rate-limit
Open

fix(import): remove rate limit from chunk endpoints — closes #113 regression#119
fabiodalez-dev wants to merge 2 commits intomainfrom
fix/import-chunk-rate-limit

Conversation

@fabiodalez-dev
Copy link
Copy Markdown
Owner

@fabiodalez-dev fabiodalez-dev commented May 1, 2026

Summary

  • Removes RateLimitMiddleware(100, 60) from POST /admin/libri/import/chunk (CSV)
  • Removes RateLimitMiddleware(100, 60) from POST /admin/libri/import/librarything/chunk (LibraryThing)

The v0.5.9.6 fix (PR #109) removed the rate limit from the GET progress endpoints but left it on the chunk POST endpoints. On a fast server (no network scraping, local TSV → DB inserts), each 10-row chunk completes in <370 ms, yielding >100 chunk requests/min — enough to trigger the 429 the reporter @ctariel still observed after v0.5.9.6.

The chunk loop is sequential by design (JS while loop awaits each response), scoped to a session-bound import_id, and already gated by AdminAuthMiddleware + CsrfMiddleware. The POST /prepare endpoints (which validate and persist the uploaded file) keep their existing limits.

Test plan

  • Import a LibraryThing TSV file with >500 rows on a fast server → import should complete without 429
  • Import a CSV with >1000 rows → same
  • Verify other import functionality (CSV, LibraryThing) still works end-to-end

Closes #113 (regression that survived the v0.5.9.6 fix)

Summary by CodeRabbit

Note di rilascio

  • Bug Fixes
    • Migliorata la velocità di elaborazione per l'importazione dati CSV e LibraryThing, rimuovendo limitazioni di throttling eccessive che rallentavano le operazioni di caricamento in blocchi.

#113)

The v0.5.9.6 fix (PR #109) removed the rate limit from the progress GET
endpoints, but left RateLimitMiddleware(100, 60) on the chunk POST routes.
For fast imports without scraping (local TSV file → DB inserts only), each
10-row chunk can complete in <370 ms, yielding >100 req/min — enough to
trigger 429 mid-import.

The chunk loop is inherently rate-limited by its own sequential design
(JS awaits each response before sending the next) and is bounded by
session + CSRF + session-scoped import_id. The /prepare POST endpoints
(which validate and persist the file) keep their existing limits — those
are the actual abuse vectors, not the chunk loop.

This reopens and closes #113 (the 429 persisted in v0.5.9.6 for the
very reason the original reporter described: >500 books on a fast server).
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 1, 2026

Warning

Rate limit exceeded

@fabiodalez-dev has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 22 minutes and 41 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 4b3b87c6-7efc-4a0b-8cc3-2d40062658d4

📥 Commits

Reviewing files that changed from the base of the PR and between 5389ec8 and f01f658.

📒 Files selected for processing (1)
  • app/Routes/web.php
📝 Walkthrough

Walkthrough

Rimossi i middleware di rate limiting (RateLimitMiddleware(100, 60)) dai due endpoint di importazione chunk (/admin/libri/import/chunk e /admin/libri/import/librarything/chunk). Aggiunto commenti esplicativi che motivano l'assenza di limitazione di velocità per il processing sequenziale e session-scoped dei chunk, risolvendo il problema del fallimento degli import con grandi cataloghi.

Changes

Rimozione Rate Limiting da Endpoint di Import

Layer / File(s) Summary
Middleware Configuration
app/Routes/web.php
Rimosso RateLimitMiddleware(100, 60) dalle rotte /admin/libri/import/chunk e /admin/libri/import/librarything/chunk. Mantiene solo CsrfMiddleware() e AdminAuthMiddleware(). Aggiunto commenti che spiegano il razionale: il processing chunk è sequenziale e session-scoped (issue #113).

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minuti

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Il titolo descrive accuratamente il principale cambiamento: la rimozione del rate limit dagli endpoint di chunk per i import, e riferisce la correzione della regressione #113.
Linked Issues check ✅ Passed Le modifiche risolvono direttamente il requisito della issue #113 rimuovendo RateLimitMiddleware dagli endpoint POST /admin/libri/import/chunk e /admin/libri/import/librarything/chunk.
Out of Scope Changes check ✅ Passed Tutti i cambiamenti sono strettamente correlati alla risoluzione della regressione #113; nessuna modifica out-of-scope rilevata nei file modificati.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/import-chunk-rate-limit

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 22 minutes and 41 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@fabiodalez-dev
Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 2, 2026

✅ Actions performed

Full review triggered.

@fabiodalez-dev
Copy link
Copy Markdown
Owner Author

@coderabbitai full review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 2, 2026

✅ Actions performed

Full review triggered.

1 similar comment
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 2, 2026

✅ Actions performed

Full review triggered.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@app/Routes/web.php`:
- Around line 1271-1276: Il commento corrente dice che il vettore di abuso è il
POST `/prepare` e suggerisce implicitamente un RateLimitMiddleware, ma in realtà
né `/admin/libri/import/upload` né `/admin/libri/import/librarything/prepare`
usano RateLimitMiddleware; correggi il commento per rimuovere il riferimento a
una protezione inesistente e documenta invece le effettive difese:
`AdminAuthMiddleware` + `CsrfMiddleware` per tutti gli endpoint di import,
mantenendo la nota sulla ragione per cui non si applica il rate limit ai chunk
sequenziali (chiusura per sessione + CSRF e chunk processing sequenziale).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 4774bc3c-c376-4a0b-8771-19d1813d2ef8

📥 Commits

Reviewing files that changed from the base of the PR and between 18c168c and 5389ec8.

📒 Files selected for processing (1)
  • app/Routes/web.php

Comment thread app/Routes/web.php Outdated
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.

Import LibraryThingTSV fail after 500 books

1 participant