Skip to content

fix(agent): propagate default values to persistent store #4511

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

CuriousCorrelation
Copy link
Member

@CuriousCorrelation CuriousCorrelation commented Nov 4, 2024

This PR fixes an issue where sane default values set in the ephemeral store were not being propagated to the persistent store if the store was uninitialized or encountered a loading error. Now, if the persistent store is absent or fails to load, default values will be established in the ephemeral store and subsequently saved to the persistent store, syncing two both storage layers.

Closes HFE-645

Copy link
Contributor

@RaHehl RaHehl Nov 5, 2024

Choose a reason for hiding this comment

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

I'm not a Rust expert, but would replacing

let _ = store
.delete("registrations")
.then_some(())
.ok_or(AppError::RegistrationClearError)?;

with

if store.get("registrations").is_some() {
let _ = store
.delete("registrations")
.then_some(())
.ok_or(AppError::RegistrationClearError)?;
}

be a more robust fix?

Copy link
Member Author

@CuriousCorrelation CuriousCorrelation Nov 5, 2024

Choose a reason for hiding this comment

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

Thanks for the suggestions! It's actually a good catch and indeed part of a refactor I’m currently planning - essentially to have a more robust logging/tracing, error system and better error propagation.

The reason why I didn’t include that into the current fix was because the primary issue was uninitialized store since while the app assumed empty default store with

let app_state = Arc::new(AppState::new(app_handle.clone())?);
but didn’t translate/communicate that assumption to the disk.

We can definitely include this fix into the PR as well, we’d basically use a match statement or even better - ? error propagation and then propagate that upwards from tray.rs + some tracing for the stacktrace.

@CuriousCorrelation CuriousCorrelation force-pushed the agent/fix/persist-store branch 2 times, most recently from 178495e to 14a1455 Compare November 5, 2024 12:43
@AndrewBastin AndrewBastin force-pushed the agent/fix/persist-store branch from 43c7541 to 2a0a582 Compare November 6, 2024 09:24
@AndrewBastin AndrewBastin merged commit ecf5d9f into hoppscotch:patch Nov 6, 2024
1 check passed
@CuriousCorrelation CuriousCorrelation deleted the agent/fix/persist-store branch March 1, 2025 09:00
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.

3 participants