Error:
DynamicForm.tsx:33 Uncaught TypeError: Cannot read properties of undefined (reading 'fields')
Cause: The form configuration in the database uses an object format for sections, but the frontend expects an array format.
Incorrect Format (Object):
{
"title": "Form Title",
"sections": {
"section_key": {
"label": "Section Label",
"fields": [...]
}
}
}Correct Format (Array):
{
"title": "Form Title",
"sections": [
{
"key": "section_key",
"label": "Section Label",
"fields": [...]
}
]
}Solution:
- Update
markdown/dynamic_form_json.jsonto use array format - Re-run the seed script:
cd backend source .venv/bin/activate python seed_form.py
- Confirm creating a new version when prompted
Symptom: Changes to the form JSON file don't appear in the application.
Cause: The application now loads forms from the database, not directly from the JSON file.
Solution:
After modifying dynamic_form_json.json, run the seed script to create a new version:
cd backend
source .venv/bin/activate
python seed_form.pyError:
psycopg2.errors.NotNullViolation: column "uuid" of relation "submission" contains null values
Solution:
This was fixed in migration d050596423f8. If you encounter this:
- Ensure you're on the latest migration
- Check that the migration adds columns as nullable first, populates them, then makes them non-nullable
Symptom: Form submits successfully but PDF doesn't download.
Possible Causes:
- Logo file missing at
backend/assets/images/vglug.png - Required Python packages not installed
Solution:
cd backend
source .venv/bin/activate
pip install -r requirements.txtEnsure logo exists:
ls backend/assets/images/vglug.pngError:
Access to fetch at 'http://localhost:5000/form' from origin 'http://localhost:5173' has been blocked by CORS policy
Solution:
Check that your frontend URL is in the CORS allowed origins list in backend/app.py:
CORS(app, origins=[
'http://localhost:5173',
'http://localhost:3000',
'http://127.0.0.1:5173',
'http://127.0.0.1:5000',
'http://127.0.0.1:5001'
])cd backend
source .venv/bin/activate
python -c "
from app import create_app
from models import FormConfig
app = create_app()
with app.app_context():
active = FormConfig.query.filter_by(is_active=True).first()
if active:
print(f'Version: {active.version}')
print(f'Year: {active.year}')
print(f'Title: {active.template_json.get(\"title\")}')
else:
print('No active form found')
"from app import create_app
from models import FormConfig
app = create_app()
with app.app_context():
forms = FormConfig.query.order_by(FormConfig.year.desc(), FormConfig.version.desc()).all()
for f in forms:
print(f"Year {f.year} v{f.version} - Active: {f.is_active}")Start the backend in debug mode to see detailed logs:
cd backend
source .venv/bin/activate
FLASK_ENV=development flask run --debug- Open browser DevTools (F12)
- Go to Network tab
- Refresh the page
- Look for the
/formrequest - Check the response to see what data is being returned
from app import create_app
from models import db, FormConfig
app = create_app()
with app.app_context():
# Deactivate current version
FormConfig.query.filter_by(year=2025, is_active=True).update({'is_active': False})
# Activate previous version
prev_version = FormConfig.query.filter_by(year=2025, version=1).first()
if prev_version:
prev_version.is_active = True
db.session.commit()
print(f"Rolled back to version {prev_version.version}")
else:
print("Previous version not found")cd backend
source .venv/bin/activate
# Drop all tables
flask shell
>>> from models import db
>>> db.drop_all()
>>> db.create_all()
>>> exit()
# Re-run all migrations
flask db upgrade
# Seed initial data
python seed_form.pycd backend
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtCheck your .env file in the backend directory:
DATABASE_URL=postgresql://username:password@localhost:5432/dbname
JWT_SECRET_KEY=your-secret-key-herecd frontend
npm installFor issues not covered in this guide:
- Check the main README files
- Review the FORM_CONFIG_README.md for form configuration details
- Check browser console and backend logs for detailed error messages