Fix: REPL Input Duplication In Amazon Q CLI
Hey guys,
We've got a bit of a situation here with the Amazon Q Developer CLI, and I wanted to bring it to your attention. It seems like there's a bug that causes the REPL (Read-Eval-Print Loop) to duplicate input when you paste a large number of lines. Let's dive into the details and see what's going on. So, keep reading to fully understand this issue and learn more about the suggested solutions.
Checks
Before we get started, I want to assure you that I've done my due diligence:
- [x] I've searched the github.com/aws/amazon-q-developer-cli/issues and didn't find any duplicates of my issue. It's always good to make sure we're not reporting something that's already being addressed.
- [x] I've run
q doctor
in the affected terminal session to check for any underlying issues with my environment. Everything seems to be in order. - [x] I've also run
q restart
and replicated the issue again, just to be sure it wasn't a temporary glitch. Unfortunately, the problem persists.
Operating System
I'm running Amazon Linux 2, which might be a factor in this bug. It's always helpful to know the operating system when troubleshooting these kinds of issues.
Expected Behavior
Okay, so here's what I expected to happen:
STR (Steps to Reproduce):
- Paste input with a large number of lines into the REPL.
- Press
Ctrl + J
a few times to extend the input.
Observed Behavior
Instead of extending the input, here's what actually happened:
- The screen flickers, which is a bit disconcerting.
- More importantly, the terminal starts duplicating the input. It's like a copy-paste frenzy gone wild!
- If you scroll up, you'll see that your
Ctrl + V
input has been duplicated multiple times. This makes it really difficult to work with the REPL.
Desired Behavior
Ideally, the input should not be duplicated when trying to extend it. We want a clean and predictable REPL experience, guys.
Suggestions
I've got a suggestion that might help, even if it doesn't completely solve the underlying bug. I recommend copying Claude Code's behavior, which is to add a placeholder like [Pasted 200 lines; Ctrl + R to review]
rather than actually showing the output. The input could be stored in a buffer for later review. This approach might make the input more manageable for both users and developers/testers.
Example
To give you a clearer picture, here's an example of the kind of input that triggers the bug:
> I just performed a shaos test and I want you to anbalyse the results:
(3124) β LocalAuroraSetup git:(mainline) ./chaos-test storm
πͺοΈ Aurora MySQL Chaos Testing Suite
=====================================
πͺοΈ Starting Chaos Storm Testing...
π Validating environment variables...
β οΈ WARNING: Some passwords are identical. Consider using different passwords for better security.
β
Environment validation passed!
πͺοΈ CHAOS STORM TESTING SUITE πͺοΈ
==================================================
This creates MAXIMUM communication link failures
Rapid-fire failures every 2-5 seconds for 5 minutes
Even well-designed systems will struggle with this
β οΈ WARNING: This is EXTREME testing!
Your application WILL experience significant failures
π Starting enhanced monitoring...
π Starting Chaos Storm...
Duration: 300 seconds
Failure interval: 2-5 seconds
Press Enter to unleash the chaos storm...
π₯ [21:11:38] Resource stress: mysql-replica4 (CPU + disk)
β±οΈ [21:11:39] Failures injected: 1 | Time remaining: 300s
π [21:11:43] Network isolation: mysql-replica2
a73d46a0fe46768d61bc877de2172c359e3e52f1f473e903407426a18cbe31bb
β±οΈ [21:11:43] Failures injected: 2 | Time remaining: 295s
π₯ [21:11:45] Resource stress: mysql-replica1 (CPU + disk)
β±οΈ [21:11:45] Failures injected: 3 | Time remaining: 293s
β±οΈ [21:11:49] Failures injected: 3 | Time remaining: 289s
β±οΈ [21:11:52] Failures injected: 3 | Time remaining: 286s
πͺοΈ [21:11:57] SIMULTANEOUS FAILURE BURST!
π [21:11:57] Container stop: mysql-replica1
mysql-replica1
π₯ [21:12:02] Connection exhaustion: mysql-primary -> 4 connections
π [21:12:02] PRIMARY DATABASE FAILURE
mysql-primary
π [21:12:13] Container stop: mysql-replica1
mysql-replica1
β±οΈ [21:12:13] Failures injected: 7 | Time remaining: 265s
πͺοΈ [21:12:16] SIMULTANEOUS FAILURE BURST!
π₯π₯ [21:12:16] Multiple replica stop: 4 replicas
mysql-replica1
mysql-replica2
mysql-replica3
mysql-replica4
π [21:12:27] Network isolation: mysql-replica4
b04a960cfb6b1ecbeb2de617733ddbacb6a7b2377dfb894c371f16cff658e668
π₯ [21:12:28] Resource stress: mysql-replica3 (CPU + disk)
π₯ [21:12:28] Connection exhaustion: mysql-replica4 -> 3 connections
β±οΈ [21:12:28] Failures injected: 11 | Time remaining: 250s
π [21:12:31] Network isolation: mysql-replica1
9dc9fa628ca75d730724302402b0ef7ec7ca6edb3d9a16de3cb4139fd1c95498
β±οΈ [21:12:31] Failures injected: 12 | Time remaining: 247s
β±οΈ [21:12:36] Failures injected: 12 | Time remaining: 242s
π [21:12:39] HAProxy restart (brief outage)
β±οΈ [21:12:39] Failures injected: 13 | Time remaining: 239s
β±οΈ [21:12:43] Failures injected: 13 | Time remaining: 235s
β±οΈ [21:12:45] Failures injected: 13 | Time remaining: 233s
π₯ [21:12:48] Connection exhaustion: mysql-replica2 -> 2 connections
β±οΈ [21:12:48] Failures injected: 14 | Time remaining: 230s
π [21:12:52] Container stop: mysql-replica2
mysql-replica2
β±οΈ [21:12:52] Failures injected: 15 | Time remaining: 226s
π₯ [21:12:54] Connection exhaustion: mysql-primary -> 5 connections
β±οΈ [21:12:54] Failures injected: 16 | Time remaining: 224s
β±οΈ [21:12:59] Failures injected: 16 | Time remaining: 219s
π [21:13:03] Network isolation: mysql-replica3
8e9dd2ebbbd2cac688b4d4f172d02e97c93b076d3854342e1c39ea01c49314b8
β±οΈ [21:13:03] Failures injected: 17 | Time remaining: 215s
β±οΈ [21:13:06] Failures injected: 17 | Time remaining: 212s
π [21:13:08] Container stop: mysql-replica2
mysql-replica2
β±οΈ [21:13:08] Failures injected: 18 | Time remaining: 210s
π [21:13:12] Container stop: mysql-replica1
mysql-replica1
β±οΈ [21:13:12] Failures injected: 19 | Time remaining: 206s
πͺοΈ [21:13:16] SIMULTANEOUS FAILURE BURST!
π [21:13:16] Container stop: mysql-replica2
mysql-replica2
π₯π₯ [21:13:16] Multiple replica stop: 3 replicas
mysql-replica1
mysql-replica2
mysql-replica3
π [21:13:16] HAProxy restart (brief outage)
β±οΈ [21:13:16] Failures injected: 23 | Time remaining: 202s
π [21:13:18] PRIMARY DATABASE FAILURE
mysql-primary
β±οΈ [21:13:18] Failures injected: 24 | Time remaining: 200s
β±οΈ [21:13:21] Failures injected: 24 | Time remaining: 197s
π [21:13:23] PRIMARY DATABASE FAILURE
mysql-primary
β±οΈ [21:13:23] Failures injected: 25 | Time remaining: 195s
πͺοΈ [21:13:27] SIMULTANEOUS FAILURE BURST!
π [21:13:27] Container stop: mysql-replica1
mysql-replica1
β±οΈ [21:13:27] Failures injected: 29 | Time remaining: 191s
π [21:13:29] HAProxy restart (brief outage)
β±οΈ [21:13:29] Failures injected: 30 | Time remaining: 189s
β±οΈ [21:13:31] Failures injected: 30 | Time remaining: 187s
β±οΈ [21:13:35] Failures injected: 30 | Time remaining: 183s
β±οΈ [21:13:39] Failures injected: 30 | Time remaining: 179s
β±οΈ [21:13:41] Failures injected: 30 | Time remaining: 177s
πͺοΈ [21:13:43] SIMULTANEOUS FAILURE BURST!
π₯ [21:13:43] Connection exhaustion: mysql-replica2 -> 2 connections
π [21:13:43] Container stop: mysql-replica2
mysql-replica2
π [21:13:43] HAProxy restart (brief outage)
π₯ [21:13:43] Connection exhaustion: mysql-replica4 -> 3 connections
β±οΈ [21:13:43] Failures injected: 34 | Time remaining: 175s
π₯ [21:13:47] Connection exhaustion: mysql-primary -> 2 connections
β±οΈ [21:13:47] Failures injected: 35 | Time remaining: 171s
π₯ [21:13:49] Connection exhaustion: mysql-replica1 -> 1 connections
β±οΈ [21:13:49] Failures injected: 36 | Time remaining: 169s
π₯ [21:13:51] Connection exhaustion: mysql-replica3 -> 5 connections
β±οΈ [21:13:51] Failures injected: 37 | Time remaining: 167s
π₯ [21:13:55] Resource stress: mysql-replica2 (CPU + disk)
β±οΈ [21:13:55] Failures injected: 38 | Time remaining: 163s
Error response from daemon: container bbe2a0cfcb43a3f1544dc480447bc2836c4cefd043024d4b0755ed08800a8b0e is not running
β±οΈ [21:13:57] Failures injected: 38 | Time remaining: 161s
β±οΈ [21:14:02] Failures injected: 38 | Time remaining: 156s
β±οΈ [21:14:06] Failures injected: 38 | Time remaining: 152s
π₯ [21:14:11] Connection exhaustion: mysql-replica2 -> 2 connections
β±οΈ [21:14:11] Failures injected: 39 | Time remaining: 147s
πͺοΈ [21:14:16] SIMULTANEOUS FAILURE BURST!
π₯π₯ [21:14:16] Multiple replica stop: 4 replicas
mysql-replica1
mysql-replica2
mysql-replica3
mysql-replica4
π₯ [21:14:16] Connection exhaustion: mysql-replica1 -> 5 connections
π₯ [21:14:16] Connection exhaustion: mysql-replica3 -> 3 connections
β±οΈ [21:14:16] Failures injected: 43 | Time remaining: 142s
π₯π₯ [21:14:19] Multiple replica stop: 4 replicas
mysql-replica1
mysql-replica2
mysql-replica3
mysql-replica4
β±οΈ [21:14:19] Failures injected: 44 | Time remaining: 139s
π₯ [21:14:22] Connection exhaustion: mysql-replica3 -> 5 connections
β±οΈ [21:14:22] Failures injected: 45 | Time remaining: 136s
π₯ [21:14:26] Connection exhaustion: mysql-replica4 -> 4 connections
β±οΈ [21:14:26] Failures injected: 46 | Time remaining: 132s
β±οΈ [21:14:28] Failures injected: 46 | Time remaining: 130s
π₯ [21:14:32] Connection exhaustion: mysql-replica4 -> 1 connections
β±οΈ [21:14:32] Failures injected: 47 | Time remaining: 126s
π [21:14:34] PRIMARY DATABASE FAILURE
mysql-primary
β±οΈ [21:14:34] Failures injected: 48 | Time remaining: 124s
β±οΈ [21:14:37] Failures injected: 48 | Time remaining: 121s
β±οΈ [21:14:41] Failures injected: 48 | Time remaining: 117s
β±οΈ [21:14:46] Failures injected: 48 | Time remaining: 112s
π₯π₯ [21:14:49] Multiple replica stop: 4 replicas
mysql-replica1
mysql-replica2
mysql-replica3
mysql-replica4
β±οΈ [21:14:49] Failures injected: 49 | Time remaining: 109s
π [21:14:51] HAProxy restart (brief outage)
β±οΈ [21:14:51] Failures injected: 50 | Time remaining: 107s
β±οΈ [21:14:55] Failures injected: 50 | Time remaining: 104s
π [21:14:58] Container stop: mysql-replica2
mysql-replica2
β±οΈ [21:14:58] Failures injected: 51 | Time remaining: 100s
β±οΈ [21:15:00] Failures injected: 51 | Time remaining: 98s
πͺοΈ [21:15:04] SIMULTANEOUS FAILURE BURST!
π₯ [21:15:04] Connection exhaustion: mysql-replica2 -> 5 connections
π [21:15:04] PRIMARY DATABASE FAILURE
mysql-primary
π₯ [21:15:04] Connection exhaustion: mysql-replica4 -> 4 connections
β±οΈ [21:15:04] Failures injected: 55 | Time remaining: 94s
β±οΈ [21:15:08] Failures injected: 55 | Time remaining: 90s
β±οΈ [21:15:10] Failures injected: 55 | Time remaining: 88s
β±οΈ [21:15:13] Failures injected: 55 | Time remaining: 85s
π [21:15:16] PRIMARY DATABASE FAILURE
mysql-primary
β±οΈ [21:15:16] Failures injected: 56 | Time remaining: 82s
π₯ [21:15:20] Connection exhaustion: mysql-primary -> 4 connections
β±οΈ [21:15:20] Failures injected: 57 | Time remaining: 78s
β±οΈ [21:15:23] Failures injected: 57 | Time remaining: 75s
π₯ [21:15:25] Connection exhaustion: mysql-replica4 -> 1 connections
β±οΈ [21:15:25] Failures injected: 58 | Time remaining: 73s
β±οΈ [21:15:28] Failures injected: 58 | Time remaining: 70s
π₯ [21:15:32] Connection exhaustion: mysql-replica3 -> 1 connections
β±οΈ [21:15:32] Failures injected: 59 | Time remaining: 66s
β±οΈ [21:15:35] Failures injected: 59 | Time remaining: 63s
β±οΈ [21:15:39] Failures injected: 59 | Time remaining: 59s
π [21:15:42] Container stop: mysql-replica4
mysql-replica4
β±οΈ [21:15:42] Failures injected: 60 | Time remaining: 56s
π [21:15:47] PRIMARY DATABASE FAILURE
mysql-primary
β±οΈ [21:15:47] Failures injected: 61 | Time remaining: 51s
π [21:15:50] Container stop: mysql-replica2
mysql-replica2
β±οΈ [21:15:50] Failures injected: 62 | Time remaining: 48s
β±οΈ [21:15:54] Failures injected: 62 | Time remaining: 44s
β±οΈ [21:15:57] Failures injected: 62 | Time remaining: 41s
π [21:16:00] PRIMARY DATABASE FAILURE
mysql-primary
β±οΈ [21:16:00] Failures injected: 63 | Time remaining: 38s
β±οΈ [21:16:05] Failures injected: 63 | Time remaining: 33s
β±οΈ [21:16:07] Failures injected: 63 | Time remaining: 31s
β±οΈ [21:16:12] Failures injected: 63 | Time remaining: 26s
πͺοΈ [21:16:14] SIMULTANEOUS FAILURE BURST!
π₯ [21:16:14] Connection exhaustion: mysql-replica3 -> 1 connections
π [21:16:14] HAProxy restart (brief outage)
π₯ [21:16:14] Connection exhaustion: mysql-replica3 -> 3 connections
β±οΈ [21:16:14] Failures injected: 66 | Time remaining: 24s
π₯ [21:16:16] Connection exhaustion: mysql-primary -> 3 connections
β±οΈ [21:16:16] Failures injected: 67 | Time remaining: 22s
β±οΈ [21:16:20] Failures injected: 67 | Time remaining: 18s
π₯ [21:16:23] Connection exhaustion: mysql-primary -> 2 connections
β±οΈ [21:16:23] Failures injected: 68 | Time remaining: 15s
π₯ [21:16:25] Connection exhaustion: mysql-primary -> 1 connections
β±οΈ [21:16:25] Failures injected: 69 | Time remaining: 13s
β±οΈ [21:16:27] Failures injected: 69 | Time remaining: 11s
β±οΈ [21:16:30] Failures injected: 69 | Time remaining: 8s
β±οΈ [21:16:35] Failures injected: 69 | Time remaining: 3s
π₯ [21:16:37] Connection exhaustion: mysql-primary -> 2 connections
β±οΈ [21:16:37] Failures injected: 70 | Time remaining: 1s
β° Chaos storm duration complete!
π Chaos storm complete!
Total failures injected: 70
Actual Behavior
As I mentioned earlier, the actual behavior is that the input gets duplicated in the terminal when you try to extend it. This makes it really hard to work with the REPL, especially when dealing with large inputs.
Steps to Reproduce
To reproduce the bug, just follow these steps:
- Paste the code snippet above (or any large chunk of text) into the REPL.
- Press
Ctrl + J
a few times to try and extend the input. You should see the duplication occur.
Environment
I'm not sure if this is relevant, but here's my environment configuration:
Conclusion
So, that's the bug in a nutshell. It's a bit annoying, but hopefully, we can find a solution or workaround soon. Let me know if you guys have any thoughts or suggestions! I hope that suggested solution of showing a placeholder and storing the input in a buffer can help solve this issue. This will definitely improve the user experience when working with large inputs in the REPL. We need reliable and efficient tools that can handle complex tasks without glitching. By addressing this bug, we can make the Amazon Q Developer CLI more user-friendly and productive for developers.
Also, letβs not forget the importance of thorough testing. Running chaos tests, as demonstrated in the example, is crucial for identifying potential weaknesses in our systems. Itβs better to find these issues in a controlled environment than to have them surface in production. So, keep testing, keep reporting, and letβs make our tools better together!