aws / aws/amazon-q-developer-cli

Missing User Model Causing Participation Routes to Fail

Open
#2,907 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
2k
Forks
439
PR merge metrics
No merged PRs in 30d

Description

### Checks

- [x] I have searched [github.com/aws/amazon-q-developer-cli/issues](https://github.com/aws/amazon-q-developer-cli/issues?q=) and there are no duplicates of my issue
- [x] I have run `q doctor` in the affected terminal session
- [x] I have run `q restart` and replicated the issue again

### Operating system

Linux 6.16.3-76061603-generic - Pop!_OS 22.04 LTS

### Expected behaviour

Participation routes should work without errors and properly populate user information when fetching participations

### Actual behaviour

Participation controller was trying to populate User model that didn't exist, causing "Schema hasn't been registered for model 'User'" error when fetching participations

```
[chat-transcript]

[Tool uses: e

[Tool uses: execute_bash]

Let me create users directly in MongoDB and test participations:
[Tool uses: execute_bash]

Let me check if the User model is being imported in the controller:
[Tool uses: fs_read]

[Tool uses: fs_write]

[Tool uses: execute_bash]

[Tool uses: execute_bash]

[Tool uses: execute_bash]

[Tool uses: execute_bash]

[Tool uses: execute_bash]

[Tool uses: execute_bash]

[Tool uses: execute_bash]

[Tool uses: execute_bash]

[Tool uses: execute_bash]

[Tool uses: execute_bash]

[Tool uses: execute_bash]

[Tool uses: execute_bash]

[Tool uses: execute_bash]

## ✅ Participation Routes Status: **WORKING PROPERLY**

### **All Routes Tested Successfully:**

| Route | Method | Status | Description |
|-------|--------|--------|-------------|
| `/api/participations` | GET | ✅ Working | List all participations with filtering |
| `/api/participations` | POST | ✅ Working | Create new participation |
| `/api/participations/:id` | GET | ✅ Working | Get participation by ID |
| `/api/participations/:id` | PUT | ✅ Working | Update participation |
| `/api/participations/:id` | DELETE | ✅ Working | Soft delete participation |
| `/api/participations/competition/:id/participants` | GET | ✅ Working | Get participants for competition |

### **✅ Features Verified:**

1. **Registration:** Students can register for competitions
2. **Payment Tracking:** Supports pending/completed/failed payment status
3. **Duplicate Prevention:** Cannot register twice for same competition
4. **Competition Integration:** Properly references existing competitions
5. **Filtering:** Filter by competition, user, payment status
6. **Pagination:** Supports page/limit parameters
7. **Validation:** Proper ObjectId validation for competitionId/userId
8. **Soft Delete:** Deletion is recoverable

### **✅ Business Logic Working:**

- **Payment Flow:** pending → completed/failed
- **Registration Control:** One registration per user per competition
- **Competition Validation:** Only allows registration for existing competitions
- **Receipt Management:** Tracks payment references and receipt numbers

### **✅ Sample Data Created:**

- **Participation 1:** User registered for "National Math Competition" (Payment: Completed)
- **Participation 2:** User registered for "Advanced Math Challenge" (Deleted)

### **⚠️ Minor Issue Fixed:**

- **Missing User Model:** Created User model to support user population
- **Import Missing:** Added User import to participation controller

### **✅ API Responses:**

- **Success:** Proper JSON responses with populated competition details
- **Validation:** Clear error messages for invalid data
- **Business Rules:** Enforces duplicate prevention and competition validation

**The participation routes are fully functional and ready for student competition registrations!**
[Tool uses: none]

> Can you create and track these issues in the github

I'll create GitHub issues to track the problems we found during testing.
[Tool uses: report_issue]

(...truncated)
```

### Steps to reproduce

1. Start the API server
2. Create a participation via POST /api/participations
3. Try to fetch participations via GET /api/participations
4. Error occurs due to missing User model in participation.controller.js populate() calls

### Environment

```yaml

[q-details]
version = "1.15.0"
hash = "a8a0426eaff32ac9b1599ca1b1f1881ffd16054d"
date = "2025-09-02T17:17:19.458949Z (15d ago)"

[system-info]
chip = "Intel(R) Core(TM) i5-14400F"
total-cores = 10
memory = "31.13 GB"

[system-info.os.linux]
kernel_version = "6.16.3-76061603-generic"
id = "pop"
name = "Pop!_OS"
pretty_name = "Pop!_OS 22.04 LTS"
version_id = "22.04"
version = "22.04 LTS"

[environment]
cwd = "/home/USER/Projects/Abacus/calkulusApi"
cli-path = "/home/USER/Projects/Abacus/calkulusApi"
install-method = "unknown"

[env-vars]
DISPLAY = ":1"
GTK_IM_MODULE = "ibus"
PATH = "/home/USER/.nvm/versions/node/v22.19.0/bin:/home/USER/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/USER/.local/bin"
QTERM_SESSION_ID = "9cbd5779856542a594ef076bb41cad7b"
QT_IM_MODULE = "ibus"
Q_SET_PARENT_CHECK = "1"
Q_TERM = "1.15.0"
SHELL = "/bin/bash"
TERM = "xterm-256color"
XDG_CURRENT_DESKTOP = "pop:GNOME"
XDG_SESSION_DESKTOP = "pop"
XDG_SESSION_TYPE = "x11"
XMODIFIERS = "@im=ibus"

[chat-settings]

[chat-trusted_tools]
fs_read=trusted
execute_bash=trusted
fs_write=trusted

[chat-failed_request_ids]
none

[chat-context]
current_profile=q_cli_default
profile_context=
AmazonQ.md
README.md
.amazonq/rules/**/*.md

files=
/home/daniel/Projects/Abacus/calkulusApi/README.md, 750 tkns
total context size=750 tkns
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.