Skip to content

Fix various sncast config issues#4205

Merged
DelevoXDG merged 41 commits intomasterfrom
zdobnikau/fix-config-parsing
Apr 24, 2026
Merged

Fix various sncast config issues#4205
DelevoXDG merged 41 commits intomasterfrom
zdobnikau/fix-config-parsing

Conversation

@DelevoXDG
Copy link
Copy Markdown
Contributor

@DelevoXDG DelevoXDG commented Mar 9, 2026

Closes #3811
Closes #4027

Stack

Summary

This PR fixes the actual bugs & issues I've been able to find, and changes the sncast handling logic in a more significant way

Introduced changes

Checklist

  • Linked relevant issue
  • Updated relevant documentation
  • Added relevant tests
  • Performed self-review of the code
  • Added changes to CHANGELOG.md

@DelevoXDG DelevoXDG mentioned this pull request Mar 20, 2026
5 tasks
@DelevoXDG DelevoXDG force-pushed the zdobnikau/fix-config-parsing branch from 62ed83f to 4ee68c8 Compare March 23, 2026 12:54
@DelevoXDG DelevoXDG mentioned this pull request Mar 30, 2026
2 tasks
@DelevoXDG DelevoXDG changed the title (wip) Fix various sncast config issues Fix various sncast config issues Mar 30, 2026
@DelevoXDG DelevoXDG marked this pull request as ready for review March 30, 2026 17:13
@DelevoXDG DelevoXDG requested review from a team, ddoktorski and franciszekjob and removed request for a team March 30, 2026 17:13
Comment on lines 262 to 263
#[test]
fn empty_config_works() {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure what is the intention of the original test, should we delete it?

Original PR:
https://github.com/foundry-rs/starknet-foundry/pull/1911/changes

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I guess just a sanity check, leaving this up to you whether to keep it or not

Comment thread crates/sncast/src/helpers/configuration.rs Outdated
Comment thread crates/sncast/src/helpers/config.rs Outdated
Comment thread crates/sncast/tests/e2e/show_config.rs
Comment thread crates/sncast/src/main.rs Outdated
@DelevoXDG DelevoXDG force-pushed the zdobnikau/refactor-sncast-config branch from 23de475 to 40addaf Compare April 17, 2026 14:05
@DelevoXDG DelevoXDG force-pushed the zdobnikau/fix-config-parsing branch from 24224a4 to 93b4912 Compare April 17, 2026 14:15
Comment thread crates/sncast/src/helpers/config.rs
Comment thread crates/sncast/src/main.rs Outdated
Comment thread crates/sncast/src/main.rs
Comment thread crates/sncast/src/main.rs
)));
}
// Note: this is potentially unreachable: `get_or_create_global_config_path` should always return dir with existing config file.
// TODO: (#3436) remove this if missing global config becomes an error
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not sure if the linked issue is accurate here as it seems very general. Also what is the actual action item here, to decide whether missing global config file should be an error?

Copy link
Copy Markdown
Contributor Author

@DelevoXDG DelevoXDG Apr 20, 2026

Choose a reason for hiding this comment

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

Also what is the actual action item here, to decide whether missing global config file should be an error?

Previously, function get_global_config_path actually didn't only get the config path, but also created it, if missing. That's why I renamed it.

The original logic though allowed us to continue, even if global config is missing for some reason.

The reason for my comment is that described situation ("global config is missing") shouldn't really happen, at least in normal (non-error) circumstances, since we always create the dir instead.

There are some cases where it can:

  • Missing HOME dir on the os
  • Some fs permission issues, disallowing us from creating config file

So the question is:

  • Should we proceed execution in these cases, as was done before?
  • Or should we treat these as hard errors?

  1. If we treat them as hard errors, then all these global_maybe_config == MaybeConfig::NoFile cases become effectively unreachable.
  2. If we keep it as it, we:
    • treat them as errors when unable to resolve requested --profile
    • proceed execution with a warning otherwise

I think I attached the wrong issue though, it was planned to be handled under now closed #4184

Since this is getting very confusing, I suggest we either create a new issue, or (even better imo) decide on the final approach now 😄

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As discussed offline I'd lean towards a hard error, but given that so far we proceeded in such cases it also makes perfect sense to only display a warning. Both options work for me, let's choose one of these and address it in scope of this or next PR

Comment thread crates/sncast/src/helpers/config.rs Outdated
Comment on lines 262 to 263
#[test]
fn empty_config_works() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I guess just a sanity check, leaving this up to you whether to keep it or not

@DelevoXDG DelevoXDG force-pushed the zdobnikau/fix-config-parsing branch from 793e730 to 1978e97 Compare April 20, 2026 11:07
Comment thread crates/sncast/src/main.rs Outdated
Base automatically changed from zdobnikau/refactor-sncast-config to master April 23, 2026 12:44
- regular `runner` uses tempdir (so effectively empty global config; previously: dependend on local machine)
- allows overriding global config dir (previously: no mechanism to test global config)
@DelevoXDG DelevoXDG force-pushed the zdobnikau/fix-config-parsing branch from a697315 to 6894e2e Compare April 23, 2026 13:18
@DelevoXDG DelevoXDG merged commit 423e9a7 into master Apr 24, 2026
24 of 25 checks passed
@DelevoXDG DelevoXDG deleted the zdobnikau/fix-config-parsing branch April 24, 2026 08:16
DelevoXDG added a commit that referenced this pull request Apr 27, 2026
<!-- Reference any GitHub issues resolved by this PR -->

## Stack
- #4175
- #4205 
- #4249
- #4234 

## Introduced changes

<!-- A brief description of the changes -->

Allow configuring scarb profile separately from sncast config:
- `--scarb-profile` in cli
- `scarb-profile` in `snfoundry.toml` 

## Checklist

<!-- Make sure all of these are complete -->

- [ ] Linked relevant issue
- [x] Updated relevant documentation
- [ ] Added relevant tests
- [x] Performed self-review of the code
- [x] Added changes to `CHANGELOG.md`
DelevoXDG added a commit that referenced this pull request Apr 27, 2026
<!-- Reference any GitHub issues resolved by this PR -->

## Stack
- #4175
- #4205 
- #4249
- #4234 

## Introduced changes

<!-- A brief description of the changes -->

Allow configuring scarb profile separately from sncast config:
- `--scarb-profile` in cli
- `scarb-profile` in `snfoundry.toml` 

## Checklist

<!-- Make sure all of these are complete -->

- [ ] Linked relevant issue
- [x] Updated relevant documentation
- [ ] Added relevant tests
- [x] Performed self-review of the code
- [x] Added changes to `CHANGELOG.md`
die-herdplatte pushed a commit to die-herdplatte/starknet-foundry that referenced this pull request Apr 29, 2026
<!-- Reference any GitHub issues resolved by this PR -->

Towards foundry-rs#4027

## Stack
- foundry-rs#4175
- foundry-rs#4205 
- foundry-rs#4249 
- foundry-rs#4234 

## Introduced changes

<!-- A brief description of the changes -->

#### Outline

This is initial refactor of cast config handling. 

It aims to make the logic easier to reason about, removes tricky
defaults resolution (using `None` instead), removes manual raw string
approach config construction, and paves way for fixes introduced in
foundry-rs#4205


Subsequent PR introduces more significant changes that change how
configs are actually handled in more breaking way in attempt to address
various issues, while this one mainly tries to keep current logic
intact.


#### Changes
- Add `PartialCastConfig` with all fields having `None` as `Default`
value.
- Create global, local, cli `PartialCastConfig`. Then combine them (add
`Override` trait for config and it's subcomponents)
- Replace raw string approach to config in
`add_created_profile_to_configuration`

## Checklist

<!-- Make sure all of these are complete -->

- [x] Linked relevant issue
- [ ] Updated relevant documentation
- [ ] Added relevant tests
- [x] Performed self-review of the code
- [ ] Added changes to `CHANGELOG.md`

---------

Co-authored-by: Maksymilian Kowalski <126796018+MKowalski8@users.noreply.github.com>
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.

Research and refactor sncast config logic Error handling for snfoundry.toml parsing

3 participants