Fix inject template import errors and null team crashes by RustyBower · Pull Request #1114 · scoringengine/scoringengine · GitHub
Skip to content

Fix inject template import errors and null team crashes#1114

Merged
RustyBower merged 2 commits into
masterfrom
fix/inject-template-import
Feb 6, 2026
Merged

Fix inject template import errors and null team crashes#1114
RustyBower merged 2 commits into
masterfrom
fix/inject-template-import

Conversation

@RustyBower

@RustyBower RustyBower commented Feb 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Import with IDs on fresh DB: When importing inject YAML with id fields, the import would fail with "Invalid Template ID" if those IDs didn't exist in the database. Now falls through to create new templates instead of erroring.
  • Orphaned injects from unknown teams: Team names in import data (e.g., "Team0") that don't match any team in the DB were creating Inject rows with team_id=NULL. Now skips unrecognized team names.
  • Null team crashes on read: The GET template and inject scores endpoints crashed with AttributeError: 'NoneType' object has no attribute 'name' when encountering injects with null teams. Added guards.
  • end_time parsing bug: The import update path was parsing d["start_time"] for end_time. Fixed to use d["end_time"].

Test plan

  • Import inject YAML with id fields into a fresh database — should create new templates
  • Import inject YAML with team names that don't exist — should skip without creating orphaned rows
  • View/edit an inject template after import — should not 500
  • View inject scores page — should not 500
  • Import YAML with matching existing template IDs — should update them as before

🤖 Generated with Claude Code

RustyBower and others added 2 commits February 6, 2026 16:44
- Import with existing IDs now creates new templates instead of erroring
  when the template ID doesn't exist in the database
- Skip team names that don't match any team in the DB during import
  instead of creating orphaned Inject rows with null team_id
- Guard against null inject.team in GET template and scores endpoints
- Fix end_time parsing bug that incorrectly used start_time value

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
14 tests covering:
- Auth/authorization (requires login, white team only)
- Creating new templates with and without team injects
- Import with non-existent ID falls through to create (was the bug)
- Unknown team names are silently skipped (no orphaned injects)
- Updating existing templates by ID
- GET template endpoint handles null-team injects without crashing
- Scores endpoint handles null-team injects without crashing
- end_time parsed from correct field (not start_time)
- Empty data returns proper error

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@RustyBower RustyBower merged commit 5afe29e into master Feb 6, 2026
6 checks passed
@RustyBower RustyBower deleted the fix/inject-template-import branch February 6, 2026 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant