Repository navigation
Fix: Cegah 500 pada respons non-JSON dan tambah timeout di ApiService - #1804
Merged
analisopendesa merged 3 commits intoNov 23, 2026
Merged
Conversation
Respons error non-JSON (misalnya halaman HTML 502/504) membuat
$response->object()->message bernilai null sehingga terdaftar()
melempar error. Ganti dengan $response->json('message', 'Gagal mengambil data.').
Tambahkan ->timeout(10)->connectTimeout(5) pada semua pemanggilan HTTP
di ApiService agar request tidak menggantung hingga timeout bawaan.
Closes #1800
Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Contributor
|
🔄 AI PR Review sedang antri di server...
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request: Fix: Cegah 500 pada respons non-JSON dan tambah timeout di ApiService
Deskripsi
ApiService::terdaftar()membaca pesan error dengan$response->object()->message. Jika server layanan membalas non-2xx dengan body bukan JSON (misalnya halaman HTML 502/504),object()bernilainullsehingga halaman yang memakai layanan ini menghasilkan 500. Selain itu, semua pemanggilan HTTP di kelas ini tidak punya timeout, sehingga request bisa menggantung hingga timeout bawaan.Perubahan yang dilakukan:
terdaftar()memakai$response->json('message', 'Gagal mengambil data.')sehingga respons non-JSON tidak lagi memicu error.register(),terdaftar(), dangetFormRegister()memakai->timeout(10)->connectTimeout(5).tests/Unit/Services/ApiServiceTest.phpuntuk respons 502 HTML dan respons JSON 500 tanpa fieldmessage.Alasan perubahan:
terdaftar()tidak boleh error 500 hanya karena upstream mengirim HTML. Pesan gagal yang rapi sudah cukup.Dampak perubahan:
✅ Respons error non-JSON: menghasilkan array
success => falsedengan pesanGagal mengambil data., bukan 500.✅ Upstream lambat: request gagal lebih cepat dan tidak menahan worker.
✅ Perilaku sukses dan error JSON: tidak berubah; test yang sudah ada tetap lolos.
Masalah Terkait (Related Issue)
Closes #1800
#1800
Langkah untuk mereproduksi (Steps to Reproduce)
Sebelum perbaikan (masalah):
ApiService::terdaftar()(pendaftaran kerja sama).terdaftar().$response->object()->messagepadanull.Setelah perbaikan (fix):
terdaftar().json('message', ...)mengembalikan default.success => falsedengan pesanGagal mengambil data..Testing pada fitur lain yang terkait:
ApiService::register()✅ test unit yang ada lolosApiService::getFormRegister()✅ test unit yang ada lolosDaftar Periksa (Checklist)
Teknis Detail
Penjelasan Teknis
Timeout ditambahkan pada chain Http:
Konfigurasi yang berubah
Tidak ada.
Dependencies yang ditambahkan
Tidak ada dependencies baru.
Testing
Manual Testing
Automated Testing
it returns default message when terdaftar receives non-JSON error bodyit returns default message when terdaftar error JSON has no message fieldtests/Unit/Services/ApiServiceTest.php(11 test, 36 assertion) lolos denganDB_PASSWORD=rahasiaErrorException) saatApiService.phpdikembalikan ke versi awal, dan lolos setelah fixcomposer pintbelum bersih: ada warning style pada kedua file, termasuk baris yang tidak diubah PR iniBrowser Compatibility (jika applicable)
Tidak ada perubahan UI.
Breaking Changes
Tidak ada.
Migration Guide
Tidak diperlukan.
References
Catatan tambahan:
register()yang mengunggah PDF mungkin terlalu pendek pada file besar atau jaringan lambat. Mohon reviewer menilai nilainya.PermohonanController, tracking, OTP Telegram, dan service statistik) tidak termasuk PR ini. Dicatat di issue terpisah.🤖 Generated with Claude Code