FoundryNesting Flask deployment failing - ImportError on bson InvalidId after hours of fixes
scott-a11y
FREEOP

3 months ago

Issue: Flask backend deployment has been failing for hours with continuous ImportError issues.

Current Error:

```

ImportError: cannot import name 'InvalidId' from 'bson' (/opt/venv/lib/python3.11/site-packages/bson/__init__.py)

```

File: /app/database/repositories/base_repository.py line 48

Project: FoundryNesting (alert-laughter / production)

Deployment ID: 8d90bde0

What's happening:

- Multiple import errors have been appearing and fixed over the past few hours

- Current GitHub main branch appears to have fixes applied (InvalidId import no longer exists in base_repository.py)

- But Railway continues deploying from commits that still contain the errors

- Commit "Fix all relative imports across entire backend" was made 30+ mins ago

- Yet Railway is deploying "Remove BusinessMetricsTracker import from init.py" which still has the InvalidId error

Question: Is there a caching issue or deployment sync problem? Why isn't Railway picking up the latest fixes from GitHub main branch?

GitHub Repo:https://github.com/scott-a11y/FoundryNesting

$10 Bounty

3 Replies

dardameiz
PRO

3 months ago

Try pressing Cmd + K (or Ctrl + K) and select “Deploy latest commit” to force Railway to pull the latest from GitHub. If that still deploys old code, check if you have any build output folders like dist, build, or pycache committed to git - Railway might be using those cached files instead of building fresh. Add them to .gitignore and remove from git tracking.


scott-a11y
FREEOP

3 months ago

Thanks for the suggestion! I deployed the latest commit and Railway is now pulling from GitHub correctly.

However, there's a new SyntaxError that appeared:

Error:

```

File "/app/database/models/base.py", line 31

from bson import ObjectId, # pymongo 4.6+ - MongoDB document identification

^

SyntaxError: trailing comma not allowed without surrounding parentheses

```

Issue: Line 31 in src/backend/database/models/base.py has a trailing comma after ObjectId with no other imports following it. Python syntax doesn't allow a trailing comma in an import statement unless the imports are surrounded by parentheses.

Quick fix needed: Either:

1. Remove the trailing comma: from bson import ObjectId

2. Or if importing multiple items, use parentheses: from bson import (ObjectId,)

The original InvalidId import issue is now fixed, but this syntax error is blocking the deployment.


dardameiz
PRO

3 months ago

I am glad! For this is quite straightforward, in the file of: src/backend/database/models/base.py

from bson import ObjectId (,) <- delete this

because it expects there will

be more import which would be separated by a comma like this: 1,2

but id you have only one, then just 1 without the comma

you might hit another issue after this but let’s see if its working


Loading...