Skip to content

Propagate errors in register_github_issue_routine instead of panicking #120

@coderabbitai

Description

@coderabbitai

Background

Raised during review of PR #116 by @leynos.

register_github_issue_routine in tests/support/routines.rs currently panics on database error via .expect("create_routine"). It should propagate errors to callers instead.

Required changes

1. Update the function signature in tests/support/routines.rs

Change the signature from:

pub async fn register_github_issue_routine(
    db: &Arc<dyn Database>,
    engine: &RoutineEngine,
) -> Routine

to:

pub async fn register_github_issue_routine(
    db: &Arc<dyn Database>,
    engine: &RoutineEngine,
) -> Result<Routine, Box<dyn std::error::Error>>

Replace:

db.create_routine(&routine).await.expect("create_routine");

with:

db.create_routine(&routine).await?;

and return Ok(routine) at the end.

2. Update all call-sites

Update all callers of register_github_issue_routine (e.g. in tests/e2e_traces/routine_system_event.rs) to propagate the error using ? or .expect() inside the #[tokio::test] function body. (.expect() is permitted inside #[test]-attributed functions.)

Acceptance criteria

  • register_github_issue_routine returns Result<Routine, Box<dyn std::error::Error>>.
  • No .expect("create_routine") remains inside the helper function body.
  • All call-sites handle the Result appropriately.

References

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions