Skip to content

WIP: Create APIS import task and wait for status#180

Open
jraddaoui wants to merge 1 commit intodev/issue-173-apis-mockfrom
dev/issue-173-apis-import-task
Open

WIP: Create APIS import task and wait for status#180
jraddaoui wants to merge 1 commit intodev/issue-173-apis-mockfrom
dev/issue-173-apis-import-task

Conversation

@jraddaoui
Copy link
Contributor

  • Add generated APIS API client.
  • Add initial APIS API client config and implementation.
  • Add APIS activities to create import task and poll status.
  • Create preprocessing tasks for both activities.

Refs #173. Based in #179.

@jraddaoui jraddaoui requested a review from djjuhasz March 13, 2026 08:40
@jraddaoui jraddaoui self-assigned this Mar 13, 2026
@jraddaoui
Copy link
Contributor Author

Just missing the OIDC provider configuration and setup, similar to what we do in Enduro with the gotools/clientauth package.

@codecov
Copy link

codecov bot commented Mar 13, 2026

Codecov Report

❌ Patch coverage is 56.22490% with 109 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.79%. Comparing base (c222046) to head (f84fc5b).

Files with missing lines Patch % Lines
internal/workflow/preprocessing.go 48.03% 49 Missing and 4 partials ⚠️
internal/apis/create_import_task_activity.go 57.14% 18 Missing and 3 partials ⚠️
internal/apis/client.go 37.50% 15 Missing ⚠️
cmd/worker/workercmd/cmd.go 0.00% 12 Missing ⚠️
internal/apis/poll_import_task_status_activity.go 84.00% 7 Missing and 1 partial ⚠️
Additional details and impacted files
@@                     Coverage Diff                     @@
##           dev/issue-173-apis-mock     #180      +/-   ##
===========================================================
- Coverage                    61.23%   60.79%   -0.44%     
===========================================================
  Files                           43       47       +4     
  Lines                         2515     2760     +245     
===========================================================
+ Hits                          1540     1678     +138     
- Misses                         830      931     +101     
- Partials                       145      151       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

- Add generated APIS API client.
- Add initial APIS API client config and implementation.
- Add APIS activities to create import task and poll status.
- Create preprocessing tasks for both activities.
@jraddaoui jraddaoui force-pushed the dev/issue-173-apis-import-task branch from f84e56f to f84fc5b Compare March 13, 2026 09:03
Copy link
Contributor

@djjuhasz djjuhasz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good @jraddaoui. I had a handful of minor notes, but the structure looks good. I think it's a really good decision to add a config gate for the APIS functionality so the workflow can run without communicating with the APIS server if necessary.

if c.Timeout < 0 {
return fmt.Errorf("invalid APIS timeout: %s", c.Timeout)
}
if c.PollInterval <= 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why aren't you setting the PollInterval to the DefaultPollInterval when the config value is 0, like you do for the Timeout?

return nil, fmt.Errorf("create APIS import task: %w", err)
}

switch res := res.(type) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shadowing the res variable.

))
}
return &CreateImportTaskResult{TaskID: taskID}, nil
case *gen.APIImportTasksPostBadRequest:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, ogen creates a new error type for every error response status code, that's just an alias for gen.CreateImportTaskResponse?! I guess so we can do this kind of type checking? It seems like it would be easier to just check a statusCode value. 😕

It would be nice if ogen also defined a common interface so we could do something like:

func createImportTaskResponseError(r gen.ErrorGetter) string {
    err, ok := r.GetError().Get()
    ...
}

) (*CreateImportTaskResult, error) {
metadata, err := os.Open(params.SIP.MetadataPath)
if err != nil {
return nil, temporal.NewNonRetryableError(fmt.Errorf("open metadata.xml: %v", err))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I should probably be using temporal.NewNonRetryableError() more. 🤔


func NewPollImportTaskStatusActivity(client Client, pollInterval time.Duration) *PollImportTaskStatusActivity {
if pollInterval <= 0 {
pollInterval = 30 * time.Second
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should use apis.DefaultPollInterval.

Temporal.TaskQueue: missing required value
Temporal.WorkflowName: missing required value`,
Temporal.WorkflowName: missing required value
missing APIS URL`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this validation error should follow the pattern of the other error messages, i.e. APIS.URL: missing required value

`,
wantFound: true,
wantErr: `invalid configuration
missing APIS URL`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be APIS.URL: missing required value

`,
wantFound: true,
wantErr: `invalid configuration
invalid APIS timeout: -1s`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be: APIS.Timeout: value -1s is less than the minimum value of 0 (or similar)

`,
wantFound: true,
wantErr: `invalid configuration
invalid APIS poll interval: -1s`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be: APIS.PollInterval: value -1s is less than the minimum value of 0 (or similar)

apis.CreateImportTaskActivityName,
&apis.CreateImportTaskParams{
SIP: sip,
Username: "preprocessing-sfa", // TODO: Use real username.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to update this. ;)

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.

2 participants