Skip to content

Conversation

darinkrauss
Copy link
Contributor

  • Refactor twiist data ingestion to find TidepoolLinkID via ProviderSession
  • Refactor ListUserProviderSessions to ListProviderSessions
  • Add UserID to ProviderSessionFilter
  • Add LastDataSetID to Source
  • Update Abbott submodule
  • Update dependencies to resolve vulnerabilities
  • Update Go version to resolve vulnerabilities
  • https://tidepool.atlassian.net/browse/BACK-3925

… ProviderSession

- Refactor twiist data ingestion to find TidepoolLinkID via ProviderSession
- Refactor ListUserProviderSessions to ListProviderSessions
- Add UserID to ProviderSessionFilter
- Add LastDataSetID to Source
- Update Abbott submodule
- Update dependencies to resolve vulnerabilities
- Update Go version to resolve vulnerabilities
- https://tidepool.atlassian.net/browse/BACK-3925
@darinkrauss darinkrauss requested a review from toddkazakov August 6, 2025 15:50
Copy link
Contributor

@toddkazakov toddkazakov left a comment

Choose a reason for hiding this comment

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

The biggest issue that I see is that we're potentially allowing data ingestion to a disconnected source. Let me know if I'm missing something.

@@ -16,9 +16,9 @@ import (

func (r *Router) ProviderSessionsRoutes() []*rest.Route {
return []*rest.Route{
rest.Get("/v1/users/:userId/provider_sessions", serviceApi.RequireServer(r.ListUserProviderSessions)),
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we keep this for backward compatibility or is it only used by other platform services?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since this endpoint required a server token (i.e. serviceApi.RequireServer) I did a search through all of the backend code for provider_sessions (and downstream usages, specifically ListUserProviderSessions) and it was not used anywhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The new endpoint ListProviderSessions is used now by the twiist data ingestion code in the data service to communicate with the auth service.


dataSources, err := dataServiceContext.DataSourceClient().ListAll(ctx, filter, nil)
// Find matching data source
dataSourceFilter := &dataSource.Filter{
Copy link
Contributor

Choose a reason for hiding this comment

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

I see that the filter for the state has been removed, perhaps by accident. I think we should check that the data source is in connected state.

Copy link
Contributor Author

@darinkrauss darinkrauss Aug 12, 2025

Choose a reason for hiding this comment

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

In this case, the data source is found through the provider session and it must be in a connected state (otherwise it is a logic error). I guess the question here is what to do about it if the logic error happens:

  1. Log the inconsistency,
  2. Force the data source state to connected,
  3. Disconnect the provider session and update the data source to remove the providerSessionId.

I did a database query and didn't find any in this state on any environment. So, I think I'll just log the inconsistency as a warning.

func (s *Source) LastDataSetID() *string {
if s.DataSetIDs == nil {
return nil
} else if length := len(*s.DataSetIDs); length < 1 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
} else if length := len(*s.DataSetIDs); length < 1 {
} else if length := len(*s.DataSetIDs); length == 0 {

@darinkrauss darinkrauss force-pushed the BACK-3925-refactor-twiist-data-ingestion branch from 7e99100 to 76888a6 Compare August 13, 2025 04: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.

2 participants