Validation errors use abort codes
Review this Python form-submission endpoint's validation.
What a strong answer looks like
Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.
0:00 of about 24 min
Mark a line and say what kind of problem it is.0 findings
1@app.route('/api/applications', methods=['POST'])
2def create_application():
3 data = request.get_json()
4 if not data.get('email'):
5 abort(400, 'email is required')
6 if '@' not in data['email']:
7 abort(400, 'email is invalid')
8 if not data.get('name'):
9 abort(400, 'name is required')
10 if len(data.get('resume', '')) > 100000:
11 abort(400, 'resume too long')
12 app_id = save_application(data)
13 return jsonify({'id': app_id}), 201
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.
Run or narrate your approach, then ask the coach.