text:
git reword on a public commit loses the message edits, wrong hint in error message

Description of the bug

Be on a public commit (main branch).
Do git reword.

Expected behavior
You get an error message telling you to use the --force-rewrite option.
Actual behavior
The editor opens, lets you edit the commit message. After saving the message, you get an error message and the edits are lost.
Moreover, the message tells you to use an --force option, which doesn't exist.
The exact error I got:
You are trying to rewrite 1 public commit, such as: 51298b4 Instead of c_restow, try c.restow
It is generally not advised to rewrite public commits, because your
collaborators will have difficulty merging your changes.
Retry with -f/--force to proceed anyways.

Version of rustc
No response
Automated bug report
Software version
git-branchless 0.4.0 (v0.3.6-nixos.0-494-gedb6e91)
Operating system
Linux 5.10.120-16471-g167ad2e5dcba
Command-line
git-branchless_dev bug-report

Environment variables
SHELL=/usr/bin/fish
EDITOR=vim

Git version
> git version
git version 2.30.2

Hooks

Show 6 hooks
Hook post-commit
#!/bin/sh
## START BRANCHLESS CONFIG

git branchless hook-post-commit "$@"

## END BRANCHLESS CONFIG

Hook post-merge
#!/bin/sh
## START BRANCHLESS CONFIG

git branchless hook-post-merge "$@"

## END BRANCHLESS CONFIG

Hook post-rewrite
#!/bin/sh
## START BRANCHLESS CONFIG

git branchless hook-post-rewrite "$@"

## END BRANCHLESS CONFIG

Hook post-checkout
#!/bin/sh
## START BRANCHLESS CONFIG

git branchless hook-post-checkout "$@"

## END BRANCHLESS CONFIG

Hook pre-auto-gc
#!/bin/sh
## START BRANCHLESS CONFIG

git branchless hook-pre-auto-gc "$@"

## END BRANCHLESS CONFIG

Hook reference-transaction
#!/bin/sh
## START BRANCHLESS CONFIG

# Avoid canceling the reference transaction in the case that `branchless` fails
# for whatever reason.
git branchless hook-reference-transaction "$@" || (
echo 'branchless: Failed to process reference transaction!'
echo 'branchless: Some events (e.g. branch updates) may have been lost.'
echo 'branchless: This is a bug. Please report it.'
)

## END BRANCHLESS CONFIG

Events

Show 5 events
Event ID: 238, transaction ID: 991 (message: hide)

ObsoleteEvent { timestamp: 1661646039.3376951, event_tx_id: EventTransactionId(991), commit_oid: NonZeroOid(901f990cf5816bbe8519ac98a913be2a520f5d05) }
ObsoleteEvent { timestamp: 1661646039.3376951, event_tx_id: EventTransactionId(991), commit_oid: NonZeroOid(b0eb5dcfd556018e5db3ea0725e8530e0eb730dd) }
ObsoleteEvent { timestamp: 1661646039.3376951, event_tx_id: EventTransactionId(991), commit_oid: NonZeroOid(84ad5109376996ac9a3a28a01ed042c3978c8fad) }
ObsoleteEvent { timestamp: 1661646039.3376951, event_tx_id: EventTransactionId(991), commit_oid: NonZeroOid(7244e1081ab525dc9d2be9d9391518b89dae94d8) }
ObsoleteEvent { timestamp: 1661646039.3376951, event_tx_id: EventTransactionId(991), commit_oid: NonZeroOid(f9689c1f2db03870e4fe43079bcdb28dd565d85c) }
ObsoleteEvent { timestamp: 1661646039.3376951, event_tx_id: EventTransactionId(991), commit_oid: NonZeroOid(85b3f46b9855600799f3ac8749d688f02bef2320) }
ObsoleteEvent { timestamp: 1661646039.3376951, event_tx_id: EventTransactionId(991), commit_oid: NonZeroOid(d1905c643e774abe7029c9c3a35c2ffd156d66a0) }
ObsoleteEvent { timestamp: 1661646039.3376951, event_tx_id: EventTransactionId(991), commit_oid: NonZeroOid(9a41b9d96fda8de3bcc5cca6f7c27ebb2c13ead3) }
ObsoleteEvent { timestamp: 1661646039.3376951, event_tx_id: EventTransactionId(991), commit_oid: NonZeroOid(a90236a1e3b9f2a9f38624d4a56899bb29a85fa9) }

:
O f9d37fd 1y xxxxxxxxxxxxx xxxxxxxxx
|\
: o 2c2e01f 1y (redacted-ref-0) xxxxxxx
:
O 203eb07 1y xxxxxx xxxxxxxxx
|\
: o 33368fc 15m xxx xx xxx xxxxx xxxx
: |
: o eff2aeb 15m xxxx xxxxxxx xxxxxxx
: |
: o 43d58a0 15m xxxxx xxxx xxxxx
: |
: o 9ee968a 15m xxxxxx xxxxxxxxx x xxxxxxx
: |
: o f67646c 15m xxxx xxxxxxxxxx xx xxxxxxxxxxxxxxxxxx
: |
: o 2c52457 15m xxxxxxxxx
: |
: o 77a2545 15m xxxx xxxxxxxxx
: |
: o 6459e14 15m xxxx
: |
: o 26677fb 15m xxxx xxx xxxxxxxxx
: |
: o ec3106f 15m xxxxxxxx xxxxx xxxxx xxxxxx
: |
: o 75e76c4 15m xxxxxxx xx xxxxx xxxxx
: |
: o 59b684d 15m xxxx xxxxxx xxx x xxxxxxx xxxxxxxxxxx
: |
: o 26b4a60 15m xxx xxx xxxx xxxxxxxxxxxx xxxxxx
: |
: o 564e98d 14m xxxx xxxxxxxx
: |
: o b47acc2 14m xxxxxxxx xxx xxxx
: |
: o 0459f8c 14m xxxx xxxx xxxxxxx
: |
: o cd72f1e 14m xxxx
:
O 5b87cf4 1y xxxx xxxxxxx xxxxxxx
|\
| o 086af61 1y (redacted-ref-1) xxx xxxxxxx xxxxx
|\
: o 3de8449 1y (redacted-ref-2) xxxxxx xxxxxx
:
O 52e228b 1y xxxx xxxxxxxxxx xx xxxxxxxxxxxxxxxxxx
|\
| o d5cabf1 1y xxxxxxxxx
| |
| o 3496d15 1y (redacted-ref-3) xxxx
|
O b4a5670 1y xxxxxxxxx
|\
: o 28dac6f 1y xxxxxxx xxx xxxx xx
: |
: o 2009b61 1y xxxxxx xxxxxxxxx
: |
: o 710c199 1y xxxxx xxxxxx
: |
: o 64cf677 1y xxxx xxxxxx
: |
: o 7d8a0b5 1y (redacted-ref-4) xxxxxx xxxxxx
:
O 0785bdf 1y xxxxx xxxxx
|\
: o fdbc603 1y (redacted-ref-5) xx xxxxxxxxx
:
O 083db6b 104d xxxxx xxxxxx
|\
: o ae9ffe3 104d (redacted-ref-6) xxxxxxxx xxxxxxx
:
O aa795d2 97d xxxx xxxxxx xxxxxxxxxx x xxxx xxxx
|\
: o d0badf6 97d (redacted-ref-7) xxxx xxxxx xxx xxxx
:
O a4a51c3 14m xxx xxxx xxxx xxxxxx
|\
: o 461c683 7m (redacted-ref-8) xxxxxxxxxxx xxxxxxxx xx xxx xxxxxxxxxxxxxxx xx xx
:
@ 51298b4 14m (redacted-ref-9, remote origin/main) xxxxxxx xx xxxxxxxxx xxx xxxxxxxx

Event ID: 234, transaction ID: 987 (message: move)

RefUpdateEvent { timestamp: 1661646003.0112278, event_tx_id: EventTransactionId(987), ref_name: "refs/heads/redacted-ref-8", old_oid: 7842f3b4245efb9441dccfcacd4b409cc51e3f1e, new_oid: 461c683c214fd023e66caaa8f0ca79df47e7b69c, message: None }
RewriteEvent { timestamp: 1661646003.1750474, event_tx_id: EventTransactionId(987), old_commit_oid: 7842f3b4245efb9441dccfcacd4b409cc51e3f1e, new_commit_oid: 461c683c214fd023e66caaa8f0ca79df47e7b69c }
WorkingCopySnapshot { timestamp: 1661646003.2148836, event_tx_id: EventTransactionId(987), head_oid: 51298b485b9737a7d121d3febef3d9961a267d9e, commit_oid: NonZeroOid(fff1dcfc54ead137818ad556a8c0c52963fb2f8a), ref_name: None }
RefUpdateEvent { timestamp: 1661646003.2996902, event_tx_id: EventTransactionId(987), ref_name: "HEAD", old_oid: 51298b485b9737a7d121d3febef3d9961a267d9e, new_oid: 51298b485b9737a7d121d3febef3d9961a267d9e, message: None }

:
O f9d37fd 1y xxxxxxxxxxxxx xxxxxxxxx
|\
: o 2c2e01f 1y (redacted-ref-0) xxxxxxx
:
O 203eb07 1y xxxxxx xxxxxxxxx
|\
: o 33368fc 15m xxx xx xxx xxxxx xxxx
: |
: o eff2aeb 15m xxxx xxxxxxx xxxxxxx
: |
: o 43d58a0 15m xxxxx xxxx xxxxx
: |
: o 9ee968a 15m xxxxxx xxxxxxxxx x xxxxxxx
: |
: o f67646c 15m xxxx xxxxxxxxxx xx xxxxxxxxxxxxxxxxxx
: |
: o 2c52457 15m xxxxxxxxx
: |
: o 77a2545 15m xxxx xxxxxxxxx
: |
: o 6459e14 15m xxxx
: |
: o 26677fb 15m xxxx xxx xxxxxxxxx
: |
: o ec3106f 15m xxxxxxxx xxxxx xxxxx xxxxxx
: |
: o 75e76c4 15m xxxxxxx xx xxxxx xxxxx
: |
: o 59b684d 15m xxxx xxxxxx xxx x xxxxxxx xxxxxxxxxxx
: |
: o 26b4a60 15m xxx xxx xxxx xxxxxxxxxxxx xxxxxx
: |
: o 564e98d 14m xxxx xxxxxxxx
: |
: o b47acc2 14m xxxxxxxx xxx xxxx
: |
: o 0459f8c 14m xxxx xxxx xxxxxxx
: |
: o cd72f1e 14m xxxx
:
O 5b87cf4 1y xxxx xxxxxxx xxxxxxx
|\
| o 086af61 1y (redacted-ref-1) xxx xxxxxxx xxxxx
|\
: o 3de8449 1y (redacted-ref-2) xxxxxx xxxxxx
:
O 52e228b 1y xxxx xxxxxxxxxx xx xxxxxxxxxxxxxxxxxx
|\
| o d5cabf1 1y xxxxxxxxx
| |
| o 3496d15 1y (redacted-ref-3) xxxx
|
O b4a5670 1y xxxxxxxxx
|\
: o 28dac6f 1y xxxxxxx xxx xxxx xx
: |
: o 2009b61 1y xxxxxx xxxxxxxxx
: |
: o 710c199 1y xxxxx xxxxxx
: |
: o 64cf677 1y xxxx xxxxxx
: |
: o 7d8a0b5 1y (redacted-ref-4) xxxxxx xxxxxx
:
O 0785bdf 1y xxxxx xxxxx
|\
: o fdbc603 1y (redacted-ref-5) xx xxxxxxxxx
:
O 083db6b 104d xxxxx xxxxxx
|\
: o ae9ffe3 104d (redacted-ref-6) xxxxxxxx xxxxxxx
:
O aa795d2 97d xxxx xxxxxx xxxxxxxxxx x xxxx xxxx
|\
: o d0badf6 97d (redacted-ref-7) xxxx xxxxx xxx xxxx
:
O a4a51c3 14m xxx xxxx xxxx xxxxxx
|\
: o 461c683 7m (redacted-ref-8) xxxxxxxxxxx xxxxxxxx xx xxx xxxxxxxxxxxxxxx xx xx
:
@ 51298b4 14m (redacted-ref-9, remote origin/main) xxxxxxx xx xxxxxxxxx xxx xxxxxxxx

Event ID: 233, transaction ID: 966 (message: pushf)

RefUpdateEvent { timestamp: 1661645611.1930046, event_tx_id: EventTransactionId(966), ref_name: "refs/remotes/origin/main", old_oid: 0000000000000000000000000000000000000000, new_oid: 51298b485b9737a7d121d3febef3d9961a267d9e, message: None }

:
O f9d37fd 1y xxxxxxxxxxxxx xxxxxxxxx
|\
: o 2c2e01f 1y (redacted-ref-0) xxxxxxx
:
O 203eb07 1y xxxxxx xxxxxxxxx
|\
: o 33368fc 15m xxx xx xxx xxxxx xxxx
: |
: o eff2aeb 15m xxxx xxxxxxx xxxxxxx
: |
: o 43d58a0 15m xxxxx xxxx xxxxx
: |
: o 9ee968a 15m xxxxxx xxxxxxxxx x xxxxxxx
: |
: o f67646c 15m xxxx xxxxxxxxxx xx xxxxxxxxxxxxxxxxxx
: |
: o 2c52457 15m xxxxxxxxx
: |
: o 77a2545 15m xxxx xxxxxxxxx
: |
: o 6459e14 15m xxxx
: |
: o 26677fb 15m xxxx xxx xxxxxxxxx
: |
: o ec3106f 15m xxxxxxxx xxxxx xxxxx xxxxxx
: |
: o 75e76c4 15m xxxxxxx xx xxxxx xxxxx
: |
: o 59b684d 15m xxxx xxxxxx xxx x xxxxxxx xxxxxxxxxxx
: |
: o 26b4a60 15m xxx xxx xxxx xxxxxxxxxxxx xxxxxx
: |
: o 564e98d 14m xxxx xxxxxxxx
: |
: o b47acc2 14m xxxxxxxx xxx xxxx
: |
: o 0459f8c 14m xxxx xxxx xxxxxxx
: |
: o cd72f1e 14m xxxx
:
O 5b87cf4 1y xxxx xxxxxxx xxxxxxx
|\
| o 086af61 1y (redacted-ref-1) xxx xxxxxxx xxxxx
|\
: o 3de8449 1y (redacted-ref-2) xxxxxx xxxxxx
:
O 52e228b 1y xxxx xxxxxxxxxx xx xxxxxxxxxxxxxxxxxx
|\
| o d5cabf1 1y xxxxxxxxx
| |
| o 3496d15 1y (redacted-ref-3) xxxx
|
O b4a5670 1y xxxxxxxxx
|\
: o 28dac6f 1y xxxxxxx xxx xxxx xx
: |
: o 2009b61 1y xxxxxx xxxxxxxxx
: |
: o 710c199 1y xxxxx xxxxxx
: |
: o 64cf677 1y xxxx xxxxxx
: |
: o 7d8a0b5 1y (redacted-ref-4) xxxxxx xxxxxx
:
O 0785bdf 1y xxxxx xxxxx
|\
: o fdbc603 1y (redacted-ref-5) xx xxxxxxxxx
:
O 083db6b 104d xxxxx xxxxxx
|\
: o ae9ffe3 104d (redacted-ref-6) xxxxxxxx xxxxxxx
:
O aa795d2 97d xxxx xxxxxx xxxxxxxxxx x xxxx xxxx
|\
: o d0badf6 97d (redacted-ref-7) xxxx xxxxx xxx xxxx
:
O a4a51c3 14m xxx xxxx xxxx xxxxxx
|\
: o 461c683 7m (redacted-ref-8) xxxxxxxxxxx xxxxxxxx xx xxx xxxxxxxxxxxxxxx xx xx
:
@ 51298b4 14m (redacted-ref-9, remote origin/main) xxxxxxx xx xxxxxxxxx xxx xxxxxxxx

Event ID: 231, transaction ID: 964 (message: revise)

RefUpdateEvent { timestamp: 1661645605.2085924, event_tx_id: EventTransactionId(964), ref_name: "refs/heads/redacted-ref-9", old_oid: a90236a1e3b9f2a9f38624d4a56899bb29a85fa9, new_oid: 51298b485b9737a7d121d3febef3d9961a267d9e, message: None }
RefUpdateEvent { timestamp: 1661645605.2085924, event_tx_id: EventTransactionId(964), ref_name: "HEAD", old_oid: a90236a1e3b9f2a9f38624d4a56899bb29a85fa9, new_oid: 51298b485b9737a7d121d3febef3d9961a267d9e, message: None }

:
O f9d37fd 1y xxxxxxxxxxxxx xxxxxxxxx
|\
: o 2c2e01f 1y (redacted-ref-0) xxxxxxx
:
O 203eb07 1y xxxxxx xxxxxxxxx
|\
: o 33368fc 15m xxx xx xxx xxxxx xxxx
: |
: o eff2aeb 15m xxxx xxxxxxx xxxxxxx
: |
: o 43d58a0 15m xxxxx xxxx xxxxx
: |
: o 9ee968a 15m xxxxxx xxxxxxxxx x xxxxxxx
: |
: o f67646c 15m xxxx xxxxxxxxxx xx xxxxxxxxxxxxxxxxxx
: |
: o 2c52457 15m xxxxxxxxx
: |
: o 77a2545 15m xxxx xxxxxxxxx
: |
: o 6459e14 15m xxxx
: |
: o 26677fb 15m xxxx xxx xxxxxxxxx
: |
: o ec3106f 15m xxxxxxxx xxxxx xxxxx xxxxxx
: |
: o 75e76c4 15m xxxxxxx xx xxxxx xxxxx
: |
: o 59b684d 15m xxxx xxxxxx xxx x xxxxxxx xxxxxxxxxxx
: |
: o 26b4a60 15m xxx xxx xxxx xxxxxxxxxxxx xxxxxx
: |
: o 564e98d 14m xxxx xxxxxxxx
: |
: o b47acc2 14m xxxxxxxx xxx xxxx
: |
: o 0459f8c 14m xxxx xxxx xxxxxxx
: |
: o cd72f1e 14m xxxx
:
O 5b87cf4 1y xxxx xxxxxxx xxxxxxx
|\
| o 086af61 1y (redacted-ref-1) xxx xxxxxxx xxxxx
|\
: o 3de8449 1y (redacted-ref-2) xxxxxx xxxxxx
:
O 52e228b 1y xxxx xxxxxxxxxx xx xxxxxxxxxxxxxxxxxx
|\
| o d5cabf1 1y xxxxxxxxx
| |
| o 3496d15 1y (redacted-ref-3) xxxx
|
O b4a5670 1y xxxxxxxxx
|\
: o 28dac6f 1y xxxxxxx xxx xxxx xx
: |
: o 2009b61 1y xxxxxx xxxxxxxxx
: |
: o 710c199 1y xxxxx xxxxxx
: |
: o 64cf677 1y xxxx xxxxxx
: |
: o 7d8a0b5 1y (redacted-ref-4) xxxxxx xxxxxx
:
O 0785bdf 1y xxxxx xxxxx
|\
: o fdbc603 1y (redacted-ref-5) xx xxxxxxxxx
:
O 083db6b 104d xxxxx xxxxxx
|\
: o ae9ffe3 104d (redacted-ref-6) xxxxxxxx xxxxxxx
:
O aa795d2 97d xxxx xxxxxx xxxxxxxxxx x xxxx xxxx
|\
: o d0badf6 97d (redacted-ref-7) xxxx xxxxx xxx xxxx
:
O a4a51c3 14m xxx xxxx xxxx xxxxxx
|\
: o 461c683 7m (redacted-ref-8) xxxxxxxxxxx xxxxxxxx xx xxx xxxxxxxxxxxxxxx xx xx
:
@ 51298b4 14m (redacted-ref-9, remote origin/main) xxxxxxx xx xxxxxxxxx xxx xxxxxxxx

Event ID: 230, transaction ID: 960 (message: rebase)

RefUpdateEvent { timestamp: 1661645570.2667537, event_tx_id: EventTransactionId(960), ref_name: "refs/heads/redacted-ref-9", old_oid: 0000000000000000000000000000000000000000, new_oid: a90236a1e3b9f2a9f38624d4a56899bb29a85fa9, message: None }

:
O f9d37fd 1y xxxxxxxxxxxxx xxxxxxxxx
|\
: o 2c2e01f 1y (redacted-ref-0) xxxxxxx
:
O 203eb07 1y xxxxxx xxxxxxxxx
|\
: o 33368fc 15m xxx xx xxx xxxxx xxxx
: |
: o eff2aeb 15m xxxx xxxxxxx xxxxxxx
: |
: o 43d58a0 15m xxxxx xxxx xxxxx
: |
: o 9ee968a 15m xxxxxx xxxxxxxxx x xxxxxxx
: |
: o f67646c 15m xxxx xxxxxxxxxx xx xxxxxxxxxxxxxxxxxx
: |
: o 2c52457 15m xxxxxxxxx
: |
: o 77a2545 15m xxxx xxxxxxxxx
: |
: o 6459e14 15m xxxx
: |
: o 26677fb 15m xxxx xxx xxxxxxxxx
: |
: o ec3106f 15m xxxxxxxx xxxxx xxxxx xxxxxx
: |
: o 75e76c4 15m xxxxxxx xx xxxxx xxxxx
: |
: o 59b684d 15m xxxx xxxxxx xxx x xxxxxxx xxxxxxxxxxx
: |
: o 26b4a60 15m xxx xxx xxxx xxxxxxxxxxxx xxxxxx
: |
: o 564e98d 14m xxxx xxxxxxxx
: |
: o b47acc2 14m xxxxxxxx xxx xxxx
: |
: o 0459f8c 14m xxxx xxxx xxxxxxx
: |
: o cd72f1e 14m xxxx
:
O 5b87cf4 1y xxxx xxxxxxx xxxxxxx
|\
| o 086af61 1y (redacted-ref-1) xxx xxxxxxx xxxxx
|\
: o 3de8449 1y (redacted-ref-2) xxxxxx xxxxxx
:
O 52e228b 1y xxxx xxxxxxxxxx xx xxxxxxxxxxxxxxxxxx
|\
| o d5cabf1 1y xxxxxxxxx
| |
| o 3496d15 1y (redacted-ref-3) xxxx
|
O b4a5670 1y xxxxxxxxx
|\
: o 28dac6f 1y xxxxxxx xxx xxxx xx
: |
: o 2009b61 1y xxxxxx xxxxxxxxx
: |
: o 710c199 1y xxxxx xxxxxx
: |
: o 64cf677 1y xxxx xxxxxx
: |
: o 7d8a0b5 1y (redacted-ref-4) xxxxxx xxxxxx
:
O 0785bdf 1y xxxxx xxxxx
|\
: o fdbc603 1y (redacted-ref-5) xx xxxxxxxxx
:
O 083db6b 104d xxxxx xxxxxx
|\
: o ae9ffe3 104d (redacted-ref-6) xxxxxxxx xxxxxxx
:
O aa795d2 97d xxxx xxxxxx xxxxxxxxxx x xxxx xxxx
|\
: o d0badf6 97d (redacted-ref-7) xxxx xxxxx xxx xxxx
:
O a4a51c3 14m xxx xxxx xxxx xxxxxx
|\
: o 461c683 7m (redacted-ref-8) xxxxxxxxxxx xxxxxxxx xx xxx xxxxxxxxxxxxxxx xx xx
:
@ 51298b4 14m (redacted-ref-9, remote origin/main) xxxxxxx xx xxxxxxxxx xxx xxxxxxxx

Version of git-branchless
No response
Version of git
No response

There is also an additional problem: the reword command moves both the main and origin/main branch to the reworded commit. The former is good and expected, the second one puts git into an unexpected and confusing state.

The editor message is similarly lost if you try to reword a merge commit.

Hi @ilyagr. Thanks for this report.
I've opened #518 to fix the incorrect option name.
As for losing the message edits, I think the best easiest way for us to work around that will be to address #475 and start using .git/COMMIT_EDITMSG for the editor messages. (As currently implemented, we only save the edited messages if there is a problem with the message itself (mostly just different commits going into the message than are found coming out of it) and we're not able to (easily) do so later in the operation, such as when we're building or executing the rebase plan.) If the messages are always edited in the known, standard location, then it will be much easier to recover work in case of errors.

Thanks for reporting. Besides better reword commit message recovery, it would probably be best to verify the rebase plan before prompting the user for a commit message. Currently, we only verify the rebase plan as part of trying to execute it. The best approach is probably either

Create a dummy rebase plan (i.e. one that rewrites every affected commit as itself) and then either see if execution succeeds or if some verify method passes.
Just separate out the verification from the rebase plan execution. Maybe combining them was a bad idea.

authors: arxanas claytonrcarter ilyagr

repo: arxanas/git-branchless


text:
Crash with : class is not key value coding-compliant for the key(s): -hash or -debugDescription or -description

I use an instance of ObjectMapper and then configure it by adding an InCodeMappingProvider as the mappingProvider. For example :
self.mapper_ = [[ObjectMapper alloc] init];
InCodeMappingProvider *inCodeProvider = [[InCodeMappingProvider alloc] init];
[self.mapper setMappingProvider:inCodeProvider];

I have a user object like this :
@interface SSUserStats : SSObject <SSObjectMapping>

@property (nonatomic, strong, nullable) NSNumber * storeCount;
@property (nonatomic, strong, nullable) NSNumber * followerCount;
@property (nonatomic, strong, nullable) NSNumber * followeeCount;

@end

@interface SSUser : NSObject <ObjectMapping>

@property (nonatomic, strong, nullable) NSString  *userId;
@property (nonatomic, strong, nullable) NSString  *email;
@property (nonatomic, strong, nullable) NSString  *username;
@property (nonatomic, strong, nullable) NSString  *firstName;

@property (nonatomic, strong, nullable) UserStats *stats;

@property (nonatomic, strong, nullable) NSString  *profileImageFilename;
@property (nonatomic, strong, nullable) NSString  *headerImageFilename;

@end

When then I try to create a dictionary from a user object and then convert back this dictionary to an object my app crash :
SSUserStats *stats = [[SSUserStats alloc] init];
stats.storeCount = @(42);
stats.followeeCount = @(12);
stats.followerCount = @(21);

SSUser  *user = [[SSUser alloc] init];
user.firstName = @"Adrien";
user.email = @"toto@toto.com";
user.username = @"flop";
user.stats = stats;

NSDictionary *dict = [self.mapper dictionaryFromObject:user];
NSLog(@"Dic : %@", dict);
User *user2 = [self.mapper objectFromSource:dict toInstanceOfClass:[User class]];
NSLog(@"User2 : %@", [user2 description]);

First log shows :
Dic : {
    debugDescription = "<User: 0x7fa183e0cd20>";
    description = "<User: 0x7fa183e0cd20>";
    firstName = Adrien;
    email = @"toto@toto.com";;
    hash = 140331679010080;
    stats =     {
        debugDescription = "<UserStats: 0x7fa183e2dde0>";
        description = "<UserStats: 0x7fa183e2dde0>";
        followeeCount = 12;
        followerCount = 21;
        hash = 140331679145440;
        storeCount = 42;
        superclass =         {
        };
    };
    superclass = NSObject;
}

At the third line, my program crash with :
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<User 0x7fa183f22360> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key hash.'

I'm using Xcode 7, iOS 9. It's really sad because I really like this lib and the way it's architectured. My question is why : hash / superclass / debugDescription / description are processed which leads to this crash, Any idea of how I can fix this. Many thanks.

I'm updating my code to swift 2.0 and Xcode 7 this weekend, will fix it and release a new version before Monday if the fix is simple

Wow nice, this would be really good ;) Keep going the good work.

I'm having a problem reproducing this issue.
can you create a failing unit test using the models I have in the project?

source: gharchive/issue

authors: aryaxt greinaldor

repo: aryaxt/OCMapper

license: mit

license_type: permissive

license_source: bigquery


text:
Recaptcha V3?

Does this plugin support recaptcha v3?

Hey @gofish543, thanks for opening up this issue — someone else asked this earlier in the previous version of this addon for Statamic 2: https://github.com/aryehraber/statamic-recaptcha/issues/5
I am honestly not sure/convinced that Recaptcha V3 is useful, or even possible, as an easy-to-use captcha system for Statamic, but am curious to hear about other people's use cases/ideas... I asked a series of Qs in the earlier GH issue, but will copy those here and hope you (and others) can chime on the issue. Thanks!

Basically, what is it about Recaptcha V3 that you are waiting for that V2 can't already do?
In my research so far it seems like it's a worse experience on both sides (users and admins) for regular websites, depending on implementation:

The user's submission is blocked because they were marked "risky" by Google and their score is below the allowed threshold. This would mean they literally can't submit the form, or it silently fails and submissions never arrive in an admin's inbox.

We store all "risky" submissions in a spam folder and stop auto-emails from being triggered, but now the burden is put on the admin to go and check spam everyday and mark Google's incorrect "risky" submissions as not spam (triggering auto-emails, etc). Also worth noting that Statamic doesn't natively support a spam folder so this solution would be a much larger undertaking since that needs to be built and integrated, instead of the current solution which simply makes use of existing core features.

I can see V3's usefulness in larger applications where the score can lead users to an additional security flow before being allowed to take a certain action, but I just don't see that being a good solution for normal forms on a regular website.
To reiterate, I'm completely open to the idea but am currently not convinced about it in a Statamic context. For more complex Statamic projects it could be useful, but at that stage you probably want to control the actions that are taken for low/high scores meaning a generic solution like this addon wouldn't really be possible/useful.
Please share your ideas and vision for use cases, I'll happily change my mind!

I'm not convinced Recaptcha V3 is useful either. However, I was asked by my manager to add recaptcha to some Statamic forms; upon showing them the results they were disappointed to see that it wasn't Recaptcha V3.
Why? Because the captcha wasn't "invisible". I personally am against the invisible recaptcha for the same reasons you are.

Right ok, fair enough, thanks for sharing!
For now, I do not have plans (or time) to add support for Recaptcha V3 but am open to further discussion from others who are able to answer some of the key questions in my above comment — will leave this issue open for the time being.

repo: aryehraber/statamic-captcha

license: MIT

license_source: github-api


text:
Option to enable/disable captcha on different forms dynamically

I'm working on a project where the user have the option to enable/disable captcha on different forms. i have found a work around but it be nice to do it like (https://github.com/aryehraber/statamic-captcha?tab=readme-ov-file#advanced).

Hi @lamuye, I remember your previous issue (and tagged you after releasing the new "Advanced" feature).
Are you asking whether your use-case is possible, or are you asking for help getting it set up?

authors: aryehraber lamuye


text:
Move tokenized data to device

The tokenized data was living in the CPU (since tokenizer is only on the cpu), needed to move it to the gpu for scoring

it doesn't need to be moved back at the end does it?

Nope our cpu code should be able to access the tensors. Only if you're trying to do an op that's combing 2 data sources in difference devices is when issues typically arise

source: gharchive/pull-request

repo: aryn-ai/sycamore


text:
Adding onTap on ExpandablePanel

I think it's important to add callback parameter on ExpandablePanel state changed. i know that we can achieve this with listen to ExpandableController as well, but it's a little bit complicated because we need to create, listen, and dispose controller. Please consider to merge this PR :)

Any update of this pull req ?

This is a heavily desired feature.  Can this PR move forward?

@jlandau10  The solution I'm using now is to copy this repository to my personal repository (fork), then I make my own pull request that takes from this branch.

@jlandau10 The solution I'm using now is to copy this repository to my personal repository (fork), then I make my own pull request that takes from this branch.

maybe a bit better than having to re-edit the package file every time it gets cleaned, thanks!

repo: aryzhov/flutter-expandable


text:
update method

I've been using methods remove and add to perform an update. The use case for this is when an object has moved (i.e. a sprite changes position). Would be nice to have an optimized update method.

Thanks for your contribution. At least we could have an update method just wrapping add and remove.
A general update method would have to traverse the entire tree anyway to insert the updated object into correct location, which is no better than add and remove. Maybe simply check whether the object has moved out of its current node and add/remove it only in case it has.
However as the quadtree stores the very same objects whose coordinates we are modifying, the update method would need to get the updated coordinates as a separate argument and apply those changes.

authors: asaarinen martindrapeau

repo: asaarinen/qtree


text:
Laravel 10.x Compatibility

This is an automated pull request from Shift to update your package code and dependencies to be compatible with Laravel 9.x.
Before merging, you need to:

Checkout the l10-compatibility branch
Review all comments for additional changes
Thoroughly test your package

If you do find an issue, please report it by commenting on this PR to help improve future automation.

:alembic: Using this package? If you would like to help test these changes or believe them to be compatible, you may update your project to reference this branch.
To do so, temporarily add Shift's fork to the repositories property of your composer.json:
{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/laravel-shift/laravel-blade-sortable.git"
        }
    ]
}

Then update your dependency constraint to reference this branch:
{
    "require": {
        "asantibanez/laravel-blade-sortable": "dev-l10-compatibility",
    }
}

Finally, run: composer update

+1 what's the hold up? Ty

+1

authors: DRN88 MaestroArt laravel-shift

repo: asantibanez/laravel-blade-sortable


text:
Vector of proj booleans

allow SRU constructor to take a sequence of projtection sizes
change srucell projection_size parameter name to projection_size
no longer enforce that projection_size < input_size and projection_size < hidden_size
add __getitem__(self, n) to sru, to return nth layer

ooops, merging to matser by accident.

ooops, merging to matser by accident.

replaced by https://github.com/asappresearch/sru/pull/156

replaced by https://github.com/asappresearch/sru/pull/156

repo: asappresearch/sru


text:
Attribute :sectnums!: Not Honored in Final PDF

Problem Description
In document where numbering of specific sections are temporary suppred via :sectnums!: (e.g. the Introduction of each chapeter), and then resumed again in the next section (same level), the section numbers in the output HTML and PDF docs are out of synch (i.e. the PDF seems to ignore this).
The project build script don't pass any CLI options affecting section numbers (all attributes are defined in the doc header)!
Expected Solution
Asciidoctor-fopub should honour the temporary suppression and re-abilitation of section numbers in the document body, just like with the HTML backend.
Not sure if this is a problem specific to the DockBook backend or to asciidoctor-fopub, but this repo seemed the right place to create an issue for this.
Real Case Example
This is taken from a real Asciidoctor project:

source: manual_03.asciidoc
PDF output: manual.pdf

For more details, see alan-if/alan-docs#68.
The code below produces "§3.1. General Rules" in the HTML doc, which is instead numbered as §3.2 in the PDF document (due to the suppressed section being skipped):
:sectnums!:
== General Rules

The Alan language is [...]

:sectnums:
== An Adventure

The result is that the section numbering of the two documents is out of synch from thereon (for the same chapter). This is inconvenient, for one would wish for consistent sections numbering across all editions of a document/book, regardless of the output format.

This has nothing to do with fopub. If you look at the DocBook, the information is not there. So it has to do with the DocBook converter. But I'm not sure how DocBook can support turning on and off numbering. If you know of a way, we could certainly add it to the DocBook converter.

authors: mojavelinux tajmone

repo: asciidoctor/asciidoctor-fopub


text:
Include reference to KDP and their need for flattened, i.e. optimized files.

Resolves #1684.

Thanks @gregturn!

authors: gregturn mojavelinux

repo: asciidoctor/asciidoctor-pdf


text:
Font size changes between first and following page loads in Firefox

First page load:

Following page loads:

This can be replicated loading the page with CTRL+F5
This is my snippet to load asciinema:
AsciinemaPlayer.create('\/2019\/10\/rpi-ds18b20-temp-sensors\/297112.cast', document.getElementById('cast-297112.cast'), {
      cols:  103 ,
      rows:  30 ,
      poster: 'npt:0:01'
    });

Recently released v3.3.0 has an improvement to font measurements in player initialization which has a chance to solve the above problem. You may want to give it a try.

@thomasjsn have you had a chance to test with newer player version?

@thomasjsn have you had a chance to test with newer player version?

I'm still using version 1.x and haven't been working on my site for a while, so unfortunately no.

Alright, I finally found the time to upgrade to the latest version. And the issue seems to be fixed — the font size no longer changes between first and following page loads. :+1:

authors: ku1ik sickill thomasjsn

repo: asciinema/asciinema-player


text:
Form data not getting set in the requestCustomGrant method

Describe the issue:
Form data fields of the CustomGrantConfig used in the requestCustomGrant method are set to "[object Promise]" instead of provided value.
How to reproduce:

Modify the sample apps (ex: asgardeo-react-js-app) to have an additional button near logout button.
Call the requestCustomGrant method in the onClick event of the added button with following configs.

const config = {
            attachToken: false,
            data: {
                client_id: "{{clientID}}",
                grant_type: "account_switch",
                scope: "{{scope}}",
                token: "{{token}}",
            },
            id: "account-switch",
            returnResponse: true,
            returnsSession: true,
            signInRequired: true
        };

When click on the added button, you will get a response with 400 response code and form data of the request header will be set as below.

Expected behavior:

Environment information (Please complete the following information; remove  any unnecessary fields) :

SDK Version: 0.1.6

Optional Fields
Related issues:
wso2-enterprise/choreo#6561
Suggested labels:

Resolved by https://github.com/asgardeo/asgardeo-auth-js-sdk/pull/143

authors: AyeshW thivi

repo: asgardeo/asgardeo-auth-spa-sdk


text:
Update to use release

Contributor checklist

[X] Documentation

🚀 Thank you for your contribution! 🚀

authors: emtudo zachdaniel


text:
🛑 AK Home Plex is down

In 9311f6f, AK Home Plex (http://home.ashishkhokhar.com:32400/) was down:

HTTP code: 0
Response time: 0 ms

Resolved: AK Home Plex is back up in d89dbc3.

repo: ashish-khokhar/services-status


text:
Infinite loop in safe_str in celery 2.2.7

In celery.utils.encoding.safe_str, it calls safe_repr if the object is not a basestring.  However, safe_repr calls safe_str on exceptions from repr.  This leads to an infinite recursion when passed an object which is not a basestring, and throws an exception from repr.
This bug is not present in 2.3 because that has a separate _safe_str which is called out of safe_repr on exceptions.  2.3 has the more desirable behaviour of simply raising up the exception when this situation arises.
This bug was introduced in this commit:
https://github.com/ask/celery/commit/edf3b3f33acdada9264754068d9c74ee76692cd9#celery/utils/encoding.py

Thanks! 2.2.10 is up on PyPI now

authors: ask jcspray

repo: ask/celery


text:
'onmessage' not triggering in node.js

I suppose this library is meant to be used like EventSource browser interface in the nodejs, so that we could register EventSource.onmessage, EventSource.onerror and EventSource.onopen. So whenever there is a new event, the callback registered with EventSource.onmessage is triggered.
But its not working like that because of the following reason:
L185-190, the actual event type sent by the server sent event (sse) is being emitted, not the message type (which will trigger the onmessage callback), as the eventName is being set to the event name which we go from event stream.
To make it work as expected, the following lines should be changed to :
_emit('message', new MessageEvent(type, {
          data: data.slice(0, -1), // remove trailing newline
          lastEventId: lastEventId,
          origin: original(url)
}));

If it is not expected to work like EventSource in browsers, please close the issue.

This library does indeed aimto follow the EventSource API implemented in browsers. There are many tests verifying that it does.
If you believe you've found a bug, your first step should be to prove that there is a bug with a failing test.
Your second step should be to fix the failing test with.
PR #49 breaks one existing test, and you didn't add a new test.
So as it stands I think your interpretation of the spec is incorrect, but I'd be willing to reconsider if you provide a failing test and provide a link to the section of the spec we're not implementing correctly.

@m-garg I think this is related to #45, which we rejected. Thoughts?

Sorry for the misunderstanding. I though the EventSource.onmessage callback should be emitted regardless of the event type sent by the sse. I just tested it on Google Chrome, and the event type sent be the event-stream is being emitted, not the 'message' event. The 'message' event is only emitted only when there is no event type sent by the event-stream or the 'message' event type itself. This is exactly what this library does.
Closing the issue. Thank you for your time.

authors: aslakhellesoy m-garg

repo: aslakhellesoy/eventsource


text:
System crash when compile (with fix)

When i try to start the compiler using npm run compile it throws the following error
`PipeWrenchTemplate on  master [✘!?] is 📦 v1.0.0 via  v14.18.1 took 3s
❯ npm run compile

pipewrench_mod_template@1.0.0 compile /home/{me}/proyects/PZGenerator/PipeWrenchTemplate
tstl

Configuration: {
modInfo: {
name: 'My First Mod',
poster: './poster.png',
description: 'arf',
id: '12312312',
url: 'https://www.google.com,'
},
modelsDir: './src/models',
texturesDir: './src/textures',
soundDir: './src/sound',
scriptsDir: './src/scripts'
}
/home/{me}/proyects/PZGenerator/PipeWrenchTemplate/node_modules/@asledgehammer/tstl-pipewrench/dist/index.js:43
let toImport = fromImport.replaceAll('.', '/');`
I fix it by changing the tstl-pipewrench index, replacing the replaceAll  to replace('/../g', '/')
It uses a regex because sometimes Javascript doesn't add the replaceAll to some strings
this also happen in the line 79

Yeah.. I know this issue all too well. I'll take a look and see if I can fix this tonight. It's an easy one.
Thanks for reporting it.

There's a error in the fix, you should use .replace(/\./g,'/')

@esteban142536 Let me know if this issue is resolved. (use npm i again)

Yes, its working again

repo: asledgehammer/PipeWrench-Template


text:
[question] mocha and path mappings

I'm trying to migrate our mono-repo from rules_nodejs to rules_js/rules_ts and have made good progress. However, running tests with mocha doesn't work and I believe they are executed in a different manner than how it is done in rules_nodejs.
We're using paths in tsconfig to do cross-module imports which works when building. But when running the tests they fail and claim the files aren't found. Looking at the output-directory I can see that all needed files are transpiled and part of the runfiles-set. So I'm thinking it must be something with how the tests are executed.
In our WORKSPACE file I've added the following for the bins option in npm_translate_lock:
        # derived from "bin" attribute in node_modules/mocha/package.json
        "mocha": {
            "mocha": "./bin/mocha.js",
        },

And looking at your macro example in rules_js I've created a mocha_test macro looking like this:
# Inspired by https://github.com/aspect-build/rules_js/blob/main/examples/macro/mocha.bzl
load("@npm//:mocha/package_json.bzl", "bin")

def mocha_test(name, srcs, args = [], env = {}, **kwargs):
    bin.mocha_test(
        name = name,
        args = args,
        data = srcs,
        env = env,
        **kwargs
    )

Since the tests are also written in typescript we create a ts_project where srcs contain the test files and then depend on the needed modules in deps. This works perfectly fine with rules_nodejs 5.7.0 so I'm wondering if I'm missing something while migrating. I see that the output looks different compared to rules_nodejs so I'm guessing I might need some kind of adaption to how rules_js expects things.
In rules_nodejs I'm using js_library to create virtual packages that map against the paths configured in tsconfig.json where I set package_name to match the expected import. I don't see a similar option for js_library in rules_js so I guess I might need npm_link_package or similar but I've yet figured out how to make it work.
Running with rules_js 1.6.5, rules_ts 1.0.0-rc5, typescript 4.8.4, mocha 10.1.0.

https://github.com/aspect-build/rules_js/blob/main/examples/npm_package/packages/pkg_a/BUILD.bazel this might help you.
rules_nodejs and rules_js has different ways of linking 1p packages.
https://github.com/aspect-build/bazel-examples/tree/main/pnpm-workspaces is an example demonstrating this.

@fredrik-w does this help you?

So I finally had some time over to play around with this again. And I think I finally cracked it.
I was trying to the define the npm_link_package in the BUILD-file of the package itself, rather in the root of the project.
Thanks to your links and the comments in those BUILD-files I realized I was doing it wrong.
Linking it from the root of the package and then explicitly set visibility to //:__subpackages__  suddenly made things start moving. However, it appears I need to depend on the name of the link rather than the module, which I can buy as it has the package_name from npm_package and thus matches the path-alias from tsconfig.json.

However, it appears I need to depend on the name of the link rather than the module

1p packages work differently than the rules_nodejs. I see why you didn't expect that.
I take this as the solution and close the issue.

@thesayyn Yes, it was solved for me, thanks for the links :slightly_smiling_face:

authors: fredrik-w thesayyn


text:
fix: respect ts_project root_dir and out_dir for assets

Fix https://github.com/aspect-build/rules_ts/issues/436

This causes an issue if the asset file is generated by another rule.
Looks like ts_project is not using _calculate_assets_outs but directly to_out_path which skips the test that input filepath == output filepath

@YvanGuidoin can you provide an example test case? A PR adding a failing test would be best, or log an issue with a snippet reproducing it if it's easy enough.

@jbedard tried to create a testcase that gives me this issue in a PR, should we follow up there ?

Yeah, lets discuss it there 👍

authors: YvanGuidoin jbedard


text:
RCL: Exclusions and TypeScript

Fixes #13967
Fixes #13969
Internal Review Topic (direct section link)

LGTM. It’s good to go if @danroth27 is happy with it.

btw - Ignore the italics on the diff. We're not escaping like we used to, and GH doesn't follow CommonMark spec properly. This won't render in italics.

authors: guardrex javiercn


text:
Suggestion - change events declaration syntax

We have now this syntax:

CurrentCount: @currentCount

<button class="btn btn-primary" @onclick="IncrementCount">Increment</button>

@code {
  int currentCount = 0;

  void IncrementCount()
  {
    currentCount++;
  }
}

Change syntax to:
<button class="btn btn-primary" onclick="@IncrementCount">Increment</button>

To use @ symbol before name of the function which is in the code block like we use it before variable @currentCount.
And left attribute onclick= as original HTML declaration

@dmitryuck Thanks for contacting us.
We deliberately switched from
<button class="btn btn-primary" onclick="@IncrementCount">Increment</button>

to
<button class="btn btn-primary" @onclick="IncrementCount">Increment</button>

to clearly separate JavaScript events from Blazor events.
We don't plan to change the syntax again as we believe the current syntax makes thing clearer and changing it in the future would break existing apps.

authors: dmitryuck javiercn

repo: aspnet/AspNetCore


text:
Blazor missing reference by default

This issue has been moved from a ticket on Developer Community.

Hello, as you can see on screenshot the Blazor app missing reference by default, and resharper tell me to add reference.

Original Comments
Visual Studio Feedback System on 10/6/2019, 09:11 PM:
We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.
Visual Studio Feedback System on 10/11/2019, 01:10 AM:
Thank you for sharing your feedback! Our teams prioritize action on product issues with broad customer impact. See details at: https://docs.microsoft.com/en-us/visualstudio/ide/report-a-problem?view=vs-2017#faq. In case you need answers to common questions or need assisted support, be sure to use https://visualstudio.microsoft.com/vs/support/. We’ll keep you posted on any updates to this feedback.

Original Solutions
ice19942335 solved on 10/6/2019, 02:01 AM, 0 votes:
Add line in _Imports.razor@using Microsoft.AspNetCore.Components

Thanks for contacting us.
The suggested using directive is already included in the _Imports.razor in the default template.
If you've manually created a razor component and your project doesn't contain _Imports.razor (the one the default templates comes with) - simply add it.

authors: mkArtakMSFT vsfeedback


text:
Why can't I open Blazor WebAssembly App in Safari on iOS?

https://docs.microsoft.com/zh-cn/aspnet/core/blazor/supported-platforms?view=aspnetcore-3.0
This doc says that Blazor WebAssembly supported Safari on iOS and Chrome on Android,but I could't open the Blazor WebAssembly App in those browsers.
Both Safari and Chrome are latest.

Thanks for contacting us. This issue is being tracked at https://github.com/mono/mono/issues/16986


text:
Inifinite loop during model binding when using [ModelBinder] attribute

Is this a Bug or Feature request?:
Bug
Steps to reproduce (preferably a link to a GitHub repo with a repro project):
Link to repro: https://github.com/Costo/aspnetcore-binding-bug

Run project with dotnet run
Go to https://localhost:5001
Submit the Form

Expected result:

Form is submitted and server responds with 200 OK

Actual result:

Server never responds. If you attach a debugger and add a breakpoint to NumberModelBinder.BindModelAsync, you can see that the program is in an inifinite loop (see screenshot below).

Description of the problem:
The problem occurs when using a custom Model Binder for a decimal property in this model:

public class TestModel
{
    public TestInnerModel[] InnerModels { get; set; } = new TestInnerModel[0];
}

public class TestInnerModel
{
    public TestInnerModel()
    {
    }

    [ModelBinder(BinderType = typeof(NumberModelBinder))]
    public decimal Rate { get; set; }
}

During a POST, it seems that model binding is stuck in an infinite loop in CollectionModelBinder
The code of the NumberModelBinder class is actually the code of DecimalModelBinder, with internal logging code stripped out, so nothing out of the ordinary.
If the [ModelBinder] attribute is removed, the application works fine.
Version of Microsoft.AspNetCore.Mvc or Microsoft.AspNetCore.App or Microsoft.AspNetCore.All:
netcoreapp2.1 or netcoreapp2.2 with SDK 2.2.100-preview3-009430

After doing #7052 fix (3e0c75187c), minimal changes related that are specific to this issue were merged in 14b7184c09

authors: Costo dougbu


text:
Support for persistence

Currently configurations are mutable in memory but cannot be persisted back to the source of providers. This issue is to track the feature request to add the ability to persist changes made in memory. This could look like a new provider interface with a method to commit changes. We the user requests a changes to be committed we could iterate over providers looking for those which implement this interface and instruct them to persist their current contents or changes.

Should probably address https://github.com/aspnet/Configuration/issues/314 at the same time, (with a different provider interface but same pattern)

Clearing milestone for visibility

Support for persisting an IConfiguration instance is of a secondary importance - you can always implement a custom persister after all. What is important, is ability to convert typed configuration objects back to IConfiguration that is opposite to the ConfigurationBinder's
Bind(this IConfiguration configuration, object instance)
something like
Unbind(this  object instance, IConfiguration configuration)
Right now I can do it by JSONizing the object and using resulting json string as a configuration source, but it's a kludge and it's not guarantied to be symmetrical to Bind (custom JsonSerializerSettings etc etc).
This feature would be quite useful for people who write configuration management code that produces configurations instead of consuming them.

I should also like to comment on this subject. In my opinion, it is quite relevant that you can save changed configurations in memory. This should not be done automatically, of course, but the option should be provided. If I remember correctly, it was already in the old Microsoft configuration model, which was used with Windows Forms a long time ago.
It is described here:
Even if the topic is not a priority, you should not lose sight of it, because all changes are only made in memory.

Any ETA when the lib will be able to save back to the source?
Thanks

Sadly it is still impossible...

I cannot fathom such scenario where this is not an anti-pattern. I do wonder what enterprise calls for the aforesaid proposition?

For a real life scenario, I used Configuration API to access various game related settings on a game engine.
The ability to combine various configuration sources (project settings, user overrides, etc) and access them in a type safe manner is quite nice, however if the player changes some of those settings in-game, there's no way to persist back to their source as it is, which largely defeats the purpose of using the API in such a context.
Of course, an ASP.NET application wouldn't need persistence of changed configuration values, there could be many other non-web applications like my own that would benefit from such a functionality.

@mysticfall
Yes, I understand that with ASP.NET and Persistance. But all these additional developed tools have been moved to a new repository, and there it says explicitly that you can use them outside of ASP.NET as well.

@FSharpCSharp Sorry, I missed 'but' in my sentence so it could have read in the exact opposite way than what I really meant :sweat_smile:
Edited my comment now and thanks for opening a new issue in the new repository. I'll subscribed to it and hope it gets more attention soon.

Triage: we have discussed this at length several time and while arguments can be made on both sides we're taking an approach of trying to keep config simple, which means we're not going to add the complexity of persistence.

authors: 123g FSharpCSharp HaoK ahoka ajcvickers archnae divega mysticfall quanterion

repo: aspnet/Configuration


text:
Fundamentals/servers/weblistener "WebListener"

Port this doc from Katana: http://katanaproject.codeplex.com/wikipage?title=Selfhosting

Register prefixes so you don't have to run the app as admin
https cert setup

Here's a description of WebListener that can also be added to the doc: https://github.com/aspnet/ServerTests/issues/42

The blog post by Neel Bhatt is well done, here's a proposed outline for the new doc that follows a similar organization and expands on it:
What is WebListener

Server for .NET Core

WebListener is a Windows HTTP server built on the Http.Sys kernel mode driver. It exposes a number of Http.Sys features previously only available in IIS.
Built on Microsoft.Net.Http.Server which can be used independently outside of ASP.NET Core

Features

Windows Authentication
Port sharing
HTTPS with SNI
HTTP/2 over TLS (Windows 10)
Direct file transmission
Response caching
WebSockets (Windows 8)

Supported Windows versions

Windows 7 and Windows Server 2008 R2 and later

When to use it

For use on Windows, when

you want to expose the server directly to the internet and you don't want to use IIS, or
you need any of the features listed above.

Recommended for edge deployment because it's built on the existing Http.Sys HTTP stack.  Http.Sys is mature technology that protects against many kinds of attacks. Kestrel is newer, hasn't had a chance to develop as many protective features yet.

Not compatible with ASP.NET Core Module, so can't be used with IIS even if you wanted to.

Example scenario: Azure Service Fabric

can use Kestrel for internal microservice to microservice communications on private network (kestrel faster), should use WebListener for directly externally facing microservice layer.
if a cluster is not on a closed private virtual network, should use WebListener for the inter-service communication as they are open to other things contacting them on their "internal" ports.
For details link to SF docs

How to use it in ASP.NET Core apps

Install Microsoft.AspNetCore.Server.WebListener

Installs dependency Microsoft.Net.Http.Server

Main code

Remove UseKestrel and UseIISIntegration and add UseWebListener
Specify options in code, e.g. NTLM and AllowAnonymous
Code sample here

Specify options in Http.sys registry keys

For configuring things such as timeouts
Some of these can be configured in-process but the defaults are in the registry
Link to https://support.microsoft.com/en-us/kb/820129

Register prefixes so you don't have to run the app as admin

Get content from http://katanaproject.codeplex.com/wikipage?title=Selfhosting

Set up SSL certificates

SSL setup out of process for WL, vs. in-process for Kestrel
Get content from http://katanaproject.codeplex.com/wikipage?title=Selfhosting

Don't run in IIS

In VS the default launch profile is for IIS Express, but you can change it to the alternate console profile.

How to use outside of ASP.NET Core

Install Microsoft.Net.Http.Server NuGet package
Code sample here

@danroth27 the Katana content that we're porting to Docs refers to third-party tools that are unsupported but are easier to work with than netsh command line, also links to third-party blogs.  Is it OK to retain this info when we port the content?

@tdykstra I think that's fine

Here are my step-by-step notes for running a WebListener console server on Windows Server Core 2016. This was done with a VM, but could be used in a Docker for Windows container environment.
PowerShell to create a self-signed cert
New-SelfSignedCertificate -CertStoreLocation Cert:\LocalMachine\My -DnsName server0.contoso.com
Cert created with the thumbprint: C74235968895ECA9C9D50703D30CE17A7D3AEEFF
PowerShell to create a GUID to use as AppId
New-guid
Guid created: 921328e8-5cdf-4b7f-a3cc-4e50147d1521
Standard cmd Prompt commands to create the Url ACLs (80 and 443)
netsh http add urlacl url=https://+:443/ user=Users
netsh http add urlacl url=http://+:80/ user=Users
Standard cmd Prompt command to associate the cert thumb print and App Id (created above) with port 443
netsh http add sslcert ipport=0.0.0.0:443 certhash=C74235968895ECA9C9D50703D30CE17A7D3AEEFF appid={921328e8-5cdf-4b7f-a3cc-4e50147d1521}
Note: If you run the above from PowerShell rather than cmd, you may need to escape some characters to get it to work
PowerShell to Download .Net Core to the machine
Invoke-WebRequest "https://go.microsoft.com/fwlink/?LinkID=827524" -OutFile .\DotNetCoreSetup.exe -UseBasicParsing
Install .Net Core from the cmd line
.\DotNetCoreSetup.exe /install /quiet /log .\log.txt
PowerShell to Restart the computer after the install
Restart-Computer
Note: You don't need to restart, but it is a pain if you don't let the machine pick up the environment changes
PowerShell to Open the Firewall Ports and Allow Traffic to WebListener
New-NetFirewallRule -DisplayName 'HTTP(S) Inbound' -Profile @('Domain', 'Private') -Direction Inbound -Action Allow -Protocol TCP -LocalPort @('80', '443')
Copy and Run Your App on the Machine
Create a directory for your application
Copy your application into it
Type 'dotnet restore' from the cmd line
Type 'dotnet run' from the cmd line
Final Note
Make sure the .UseUrls("http://+:80", "https://+:443") call matches the URL ACLs you created with netsh earlier.
If this is not done, you may receive a 503 Service Unavailable from the web server.

Wrote a post on it here: https://blogs.msdn.microsoft.com/timomta/2016/11/04/how-do-i-set-up-a-net-core-weblistener-with-ssl/

Url configuration: https://msdn.microsoft.com/en-us/library/windows/desktop/aa364698(v=vs.85).aspx

Thanks for the blog post @timomta !

repo: aspnet/Docs


text:
aspnetcore/security/authentication/2fa/sample/WebSMS/src/WebSMS/gulpfile.js

gulpfile.js

@tdykstra  where is the project.json ref?

@tdykstra  what needs to be done? Remove gulpfile.js ?

yes

authors: Rick-Anderson tdykstra


text:
Convert Windows Services topic to use Powershell

Fixes #10833
Thanks @pherbel ... I used your ACL bits.
Notes:

We need PS6 for this: Not only is it the latest, the Remove-Service cmdlet didn't become available until PS6, and that's a nice-to-have here.

WRT granting Log on as a service rights to the user: We can't use the UserRights script:

That script doesn't work in PS6.
It's not supported by MS anyway.

However, we certainly can use a security template as I do here. @blowdart will be The First Decider on what we ultimately do.

There's no OOB way AFAICT to create a local user in PS6. For example, the New-LocalUser command of PS5.1 doesn't work. I stick with the net user command here.

As I don't know powershell that well @TravisEz13 might have some thoughts about it.

@blowdart What about the use of the security template and secedit.exe command to give the user Log on as a service privileges? It's supported and it's easy to show-'n-tell for the reader to perform. There's no supported PS way to do it ... not as far as I can tell anyway.

That's certainly novel :)

Well ... it's not as bad as my usual 😝 RexHacks 😝 around here. @shirhatti may have one or more alternatives. This is fairly easy to grok/perform tho. Seems to work well.

New-LocalUser should work in PS6.2 on windows.

I see ... I was using 6.1.3. They seem to be saying that that's the latest. Is that correct? Is 6.2 in preview?

Yeah ... I see it. It's in RC. I'll open an issue to replace that bit when 6.2 RTMs.

I just verified that New-LocalUser works at least when you don't let it prompt for a password.  I'll have to open an issue on the prompt, but that may never get fixed.

Can you point me to the UserRights script?

Cool ... I'll take care of swapping for the net user command when 6.2 RTMs.
Here it is ... https://gallery.technet.microsoft.com/scriptcenter/Grant-Revoke-Query-user-26e259b0
It broke when I tried to use it. However, it isn't supported (unless management wants to give me a pass here ... to cover my b-hind :smile:).

I think that script can be fixed (not making any claims about supportability or maintainability.  Actually, I believe it has similar issue to why New-LocalUser had to be pulled from PowerShell 6)
It's actually all C# code that is broken (So far), which is being compiled at runtime in PowerShell.  This is not a great design for cross framework compatibility.
I'm not sure I have time, but if someone want to work on it, my recommendation would be to convert it to a Net/PowerShell Standard/Windows Compat based C# PowerShell module.  This would work on Windows PowerShell (in Windows 10) and PowerShell Core.

Thanks @TravisEz13
I'll have an :ear: open for @shirhatti's feedback.

Ping @shirhatti - This one is also fairly short.
The main concern with the updates here is granting the Log on as a service right to the service account.
This PR includes a move from icacls.exe to secedit.exe (with a security template), which is fairly pointless. Now that I've :zzz:🛌:zzz: on it, I like the icacls.exe approach better.
UserRights doesn't work with PS6 and imo presents significant security risks.
Does engineering want to come up with a PS script for this step (akin to the UserRights approach) that we can trust and include with the topic? Want me to hack something together as a first pass? ... good for a laugh anyway :smile:.

Maybe I missed the memo on this, but why are we converting this doc to use Powershell?

https://github.com/aspnet/Docs/pull/10837#pullrequestreview-201724257
We can close this if you want. In addition to the inability to grant Log on as a service, New-LocalUser doesn't return until 6.2 RTM (it's RC right now; I opened https://github.com/aspnet/Docs/issues/11344 to cover it). If we do close the PR, do you want to close the issue, as well, or do you just want me to push the issue to the Backlog? (If we close both the PR and the issue, I won't bill MS for any of this work.)

Since @blowdart asked for it, I'll let him make the call.

@blowdart Ur call ... which way do u want to go? ...

icacls.exe
secedit.exe (with a security template)

I'm leaning back toward what we have in the topic today (icacls.exe) just because it doesn't require the extra template bit. It's just a command that they can execute in the shell.

... and just note to all that we're not going to make a PS script today for the Log on as a service permission, but I would like to reconsider it in the future. I'm going to open a backlog issue (P3) so that we can take another look down the road at it.

icacls please

authors: TravisEz13 blowdart guardrex shirhatti


text:
Use API Explorer based NSwag generator and middlewares

Upgrade NSwag (samples) and use new API Explorer based generators (the reflection based generators are deprecated soon)
Some text improvements
Change "Open API" to "OpenAPI" (correct name)
Use new Swagger UI 3 in samples

Internal Review Page

Thank you for the updates, @RSuter!

authors: RSuter scottaddie


text:
Use Prereqs include in 2.2 migration doc

Fixes https://github.com/aspnet/Docs/issues/9641

Not part of this PR but slightly related - your includes are still using the VS link without the campaign tracking:
https://www.visualstudio.com/downloads/?utm_medium=microsoft&utm_source=docs.microsoft.com&utm_campaign=button+cta&utm_content=download+vs2017

authors: mairaw scottaddie


text:
Raise exceptions for unsupported property setup/metadata?

I'm working on sequence support for Npgsql, and I'm wondering about what to do with properties that are impossible. I'm referring, for example, to identity columns that aren't numeric, to properties that have both DefaultValue and DefaultValueSql, or, in the PostgreSQL case, to computed columns in general which aren't really supported (although there may be alternate ways to implement this).
The current approach I see in the code is to silently ignore these invalid or unsupported "specs". Wouldn't it be better to raise exceptions for these?

@roji I think there are a couple of things we can do here. In some cases it may be fine to just throw in Migrations. For example, if it might be possible for a database to be setup with triggers, etc. to do what is asked, but there is no way to create such a database from Migrations. In cases where the model is always going to invalid then look into implementing an IModelValidator, This seems to be the place where most model validation is gravitating, and is something that providers can implement. @smitpatel can provide more info if needed.

authors: ajcvickers roji

repo: aspnet/EntityFramework


text:
Log warning if key property has default value set

Issue #6048

@rowanmiller for the warning message.

:shipit:

authors: AndriySvyryd ajcvickers


text:
Method not found: 'System.String System.AppContex t.get_TargetFrameworkName()'

Hi, I'm using last version of ef core (3.0.0-preview.19074.3), It works in my computer but not working in another computer, some computers i got this error:
System.MissingMethodException: Method not found: 'System.String System.AppContex
t.get_TargetFrameworkName()'.
   at Microsoft.EntityFrameworkCore.Metadata.Internal.ClrAccessorFactory`1.Creat
e(PropertyInfo propertyInfo, IPropertyBase propertyBase)
   at Microsoft.EntityFrameworkCore.Metadata.Internal.ClrAccessorFactory`1.Creat
e(PropertyInfo propertyInfo)
   at Microsoft.EntityFrameworkCore.Internal.DbSetFinder.<>c__DisplayClass2_0.<F
indSets>b__2(PropertyInfo p)
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at Microsoft.EntityFrameworkCore.Internal.DbSetFinder.FindSets(Type contextTy
pe)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Fu
nc`2 valueFactory)
   at Microsoft.EntityFrameworkCore.Internal.DbSetFinder.FindSets(DbContext cont
ext)
   at Microsoft.EntityFrameworkCore.Internal.DbSetInitializer.InitializeSets(DbC
ontext context)
   at Microsoft.EntityFrameworkCore.DbContext..ctor(DbContextOptions options)
   at Microsoft.EntityFrameworkCore.DbContext..ctor()
   at Azadegan.Server.DataBase.Contexts.AzadeganContext..ctor() in D:\Atitec\Old
\Azadegan\Server\Azadegan.Server.DataBase\Contexts\AzadeganContext.cs:line 63
   at Azadegan.ConsoleTest.Program.Main(String[] args) in D:\Atitec\Old\Azadegan
\Server\Azadegan.ConsoleTest\Program.cs:line 23

My line 23 is:
using (AzadeganContext context = new AzadeganContext())

EF Team Triage: This issue is lacking enough information for us to be able to effectively triage it. In particular, it is missing the following information requested in the new issue template. Can you please provide this information?

Steps to reproduce

Ideally include a complete code listing that we can run to reproduce the issue.
Alternatively, you can provide a project/solution that we can run.
BTW we're not just doing this to be mean :smile:... we get a lot traffic on this project and it takes time to attempt to reproduce an issue based on fragments of information. In addition, our attempt is often unsuccessful as the exact conditions required to hit the issue are often not explicitly included in the code provided. To ensure we maximize the time we have to work on fixing bugs, implementing new features, etc. we ask that folks give us a self-contained way to reproduce an issue.
For a guide on submitting good bug reports, read Painless Bug Tracking.
BTW this is a canned response and may have info or details that do not directly apply to this particular issue. While we'd like to spend the time to uniquely address every incoming issue, we get a lot traffic on the EF projects and that is not practical. To ensure we maximize the time we have to work on fixing bugs, implementing new features, etc. we use canned responses for common triage decisions.

EF Team Triage: Closing this issue as the requested additional details have not been provided and we have been unable to reproduce it.
BTW this is a canned response and may have info or details that do not directly apply to this particular issue. While we'd like to spend the time to uniquely address every incoming issue, we get a lot traffic on the EF projects and that is not practical. To ensure we maximize the time we have to work on fixing bugs, implementing new features, etc. we use canned responses for common triage decisions.

authors: Ali-YousefiTelori ajcvickers

repo: aspnet/EntityFrameworkCore


text:
TryValidateObject should use fluent model builder configuration

Currently TryValidateObject is only using the data annotation attributes on the models, but since it's perfectly valid to use fluent configuration (the Scaffold-DbContext command is using that for example) I think the TryValidateObject should be able to use the fluent metadata (like HasMaxLength, etc) to validate the model as well.

Who owns TryValidateObject? It is not part of EF Core.

Oh, my bad, I thought it was. It's in System.ComponentModel.DataAnnotations.Validator. Where's the correct place for this issue then?

https://github.com/dotnet/corefx/issues

authors: HakanL smitpatel


text:
[WIP] Concatenating null with not null string resulting in null

DO NOT COMMIT THIS - work in progress.
Looking for some feedback on WIP for issue #3836.
My attack plan was to include a Coalesce function call with all string concatenations. This does produce somewhat ugly SQL for a ton of common scenarios. I changed the check to only wrap references to nullable columns in Coalesce but this will miss a ton of different possible outcomes.
Looking for some guidance on what you fancy doing here, uglify everything or only cover some really specific examples?
I've not updated all the unit tests to match this change yet so there are broken tests.

Why not use concat function available in most major sql languages that supports adding null strings together?

Concat support was added in SqlServer 2012. Cannot use it since we still support SqlServer 2008.
https://docs.microsoft.com/en-us/sql/t-sql/functions/concat-transact-sql?view=sql-server-2017

SQL server 2008R2 is going EOL next month. I think it makes sense to offer concat.

@divega Looking for your input on this.

Ping @divega

Here is the requested input:

I did some looking around and there are fundamental variations in support CONCAT() across many of the most relevant databases. For example, according to what I found:

In MySQL, CONCAT() does return null if any of the arguments is null
In SQLite, CONCAT() isn't supported
In Oracle, CONCAT() only supports two arguments

Of all the databases I investigated, it seems that CONCAT() would be the most straightforward translation only for SQL Server 2012 and above, and PostgreSQL 9.1 and above. While we could aim for this, assuming we still care about older versions, we would still need a different translation using concatenation operators supported by the database. In the past we strove to stay away form runtime version detection, so presumably we would need either an opt-in or opt-out of this behavior, which adds to the cost. I don't think we need to know anyway, because we need the other translation based on concatenation operators for other databases that either don't support CONCAT() or for which CONCAT() doesn't implement the desired behavior.

Given that CONCAT() doesn't help addressing #3836 across providers, I don't see a better solution for obtaining the desired behavior than pursuing the direction of this PR. That is, add COALESCE(x,'') when we know x can be null. The generated SQL is more complicated, but that should improve a bit when we start caching generated SQL depending on sniffing parameter values. @smitpatel also mentioned that people can add their own coalesce operator code in the LINQ query to get the desired result, but that feels more like a workaround than anything. We have precedent in older versions of EF where C# semantics for string concatenation was fixed based on feedback and community PRs.

Incidentally, the concatenation operator in SQL Standard and in the majority of the databases outside of SQL Server is ||, and not +. I believe we missed making || the default in relational and now most providers need to override it.

One more detail to take into account:

Changing the behavior in this way, although and improvement, is also technically a behavioral breaking change.

Design notes:

We need to add COALESCE(column, N'') only when column can be null and is used in string concatenation.
The place where we find nullability is NullSemanticsRewritingExpressionVisitor.
Based on that, @divega, is it fair to say that if user wants database nulls behavior then null + "b" may return null rather than "b"?

Separate issue. Though as discussed, it ended up with that way because we don't special case string concat. They are a + b in tree and we always print +. That is to say, it wasn't because of SqlServer but because of ease of printing due to our Sql tree structure. We can fix it. Probably best to file an issue and put good-first-issue

Already targeting master branch so this would go into next breaking release.

(Fixed/simplified my initial write up)

Based on that, @divega, is it fair to say that if user wants database nulls behavior then null + "b" may return null rather than "b"?

Yes, I think it is reasonable for the same UseRelationalNulls flag to control both null comparisons and this. The name is a good fit, plus both behaviors are a consequence of null meaning unknown.

@muppets - Would you like to work based on new design? @maumar can guide you in terms of how NullSemanticsRewritingExpressionVisitor works.

Added design notes in original issue. Closing PR.

authors: Muppets ajcvickers divega mburbea smitpatel


text:
Support for shared projects in vNext projects

Are there any plans to support shared project references in vNext projects?

Hi, can you clarify what exactly you mean by shared project references? You can use global.json to share projects amongst different solutions, and you can use features of project.json to include source code from arbitrary locations into your project as well. Are you looking for something else?

Hi, I am talking about shared projects introduced in VS 2015. As of now, they can't be referenced from vNext projects.

Oh those look cool :smile:
I'm not sure exactly how these would interact with ASP.NET 5 projects because they are quite separate from MSBuild and have to exist outside of VS.
Adding @barrytang and @mayurid from the web tooling team, and @davidfowl from the runtime team.

This is on our backlog.

If I am not mistaken you can already mark code as shared and have that included in all referencing projects.

I sees it's now possible to reference *.csproj from *.kproj. That's all I need right now :) Thank you!

authors: Eilon barrytang borgdylan djanosik

repo: aspnet/Home


text:
Multiple Access-Control-Allow-Origin headers when using CORS in IIS

I have an ASP.NET Core project in which I use CORS. I am targeting .NET Core 2.1. I believe my settings are fairly standard, but I'll log them here to give context.
Firstly, I add some CORS policies at the start of the ConfigureServices method:
public void ConfigureServices(IServiceCollection services)
{
    services.AddCors(options =>
    {
        options.AddPolicy(
            "AllowEverything",
            builder => builder
                .AllowAnyOrigin()
                .AllowAnyHeader()
                .AllowAnyMethod());
        options.AddPolicy(
            "AllowLocalhost",
            builder => builder
                .WithOrigins("http://localhost")
                .AllowAnyHeader()
                .AllowAnyMethod()
                .AllowCredentials());
    });
    ...
}

Then I specify which policy I am using at the end of the Configure method:
public void Configure(IApplicationBuilder app, IHostingEnvironment env, IOptions<WorkflowServerSettings> settings, IApplicationLifetime applicationLifetime)
{
   ...
    app.UseCors("AllowLocalhost");
}

By the way, this is not a final implementation, so please try to resist the urge to review this too much. At least I don't use "AllowEverything" by default. :)
When I run this via IIS Express, it works fine but I have problems when I run it in IIS. (after publishing via File System.)
The problem is that a parent application has a web.config file that adds the "Access-Control-Allow-Origin" header. Unfortunately, I end up with two "Access-Control-Allow-Origin" headers in my response, and the browser does not like it.
Is this a bug? Should ASP.NET Core be replacing the existing header, or at least combining with it? I believe multiple "Access-Control-Allow-Origin" headers is an error, so i think it needs to be more robust.
I can manually fix it in IIS after the deployment but each publish re-creates the web.config and I don't know of a clean way to fix it. I could probably remove it from the context, but that seems more like a workaround than a proper implementation.

Thanks for contacting us, @kenlyon.
@javiercn, can you please look into this? Thanks!

@kenlyon This is not a bug on the MVC side. It's an issue with the web.config that gets generated at deployment time. @vijayrkn who owns this part of the publish pipeline?

the web.config generation logic is in the websdk. I can take a look.
@kenlyon - Do you have a sample project?

@vijayrkn I don't right now. It's part of something larger and I'm a bit short of time, unfortunately.
The steps to reproduce should be:

In IIS, create a Site or Application.
In the "HTTP Response Headers" add Access-Control-Allow-Origin with a value of *.
In Visual Studio, create a .NET Core Web API project. (Mine is using .NET Core 2.1)
In the Configure method of the Startup class, add the following before app.UseMcv():
app.UseCors(builder =>
builder
.WithOrigins("http://localhost")
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials());
Add a Controller with an Action (so you have an endpoint to call).
Publish to File System.
In IIS, add the published test project as a child of the Site/Application you created at the start.
Make sure the site has an https binding. (I think this is necessary for http://localhost to be considered CORS.)
Make a request from http://localhost to the endpoint using https. You should see the two Access-Control-Allow-Origin headers in the response.

I tried the steps you mentioned but I can't repro the issue.
Here is my web.config from the IIS site from Step1
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath=".\WebApplication1.exe" arguments="" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
	<httpProtocol>
		<customHeaders>
			<add name="Access-Control-Allow-Origin" value="*" />
		</customHeaders>
	</httpProtocol>
  </system.webServer>
  </location>
</configuration>

And here is the web.config generated by publish (used by the child app) in step 7

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="dotnet" arguments=".\WebApplication34.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
    </system.webServer>
  </location>
</configuration>

Do you have this line in the root website? May be that is the issue. I don't see publish re-adding any settings.
  <location path="." inheritInChildApplications="false">

In the "HTTP Response Headers" add Access-Control-Allow-Origin with a value of *.

@kenlyon why are you doing that? Returning Access-Control-Allow-Origin: * with AllowCredentials will result in browsers disallowing the request.

Closing as per @vijayrkn we can't repro the issue. CORS should be configured in a single place and the recommended place is the app as provide way more flexibility than the server.

My apologies for my delay on this. I overlooked a notification in my inbox.
@vijayrkn The parent web.config does not have <location path="." inheritInChildApplications="false">. If you literally start with a new site and add the header and do nothing else, you should be able to reproduce the problem. Could you please try again without that entry?
@pranavkm The project that I'm working on has a number of nested applications with varying requirements. For most of them, we are allowing requests from any origins.
@javiercn Would you please consider re-opening this issue? I understand that ideally CORS should be configured in a single place, but different requirements can call for more creative solutions. I believe my steps to reproduce are accurate and should work, as long as that extra <location path="." inheritInChildApplications="false"> entry is not added to the parent web.config.

If you dont have this to the parent site, then the settings will be inherited
<location path="." inheritInChildApplications="false">
Then, this is not a publish tooling problem. I will let @pranavkm & @javiercn comment on the runtime side of things.

@kenlyon I don’t see how the runtime can do anything here as we don’t see the header (presumably it gets appended to the response after the ASP.NET Core pipeline has executed) and then IIS appends the extra header.
@shirhatti is there anything the IIS CORS Module should do here? Like avoid adding the header if there’s one already present or an attribute to control this behavior?

As @vijayrkn alluded to, newer versions of the websdk add the <location path="." inheritInChildApplications="false"> in your web.config.
If you don't have it, you can still clear out all the inherited values in the customHeader collection as shown below
<configuration>
  <system.webServer>
	<httpProtocol>
		<customHeaders>
			<clear />
		</customHeaders>
	</httpProtocol>
  </system.webServer>
</configuration>

We have web.config transform support in 2.2 SDK. You can find examples here - https://github.com/vijayrkn/webconfigtransform/

I believe this issue has been resolved with @vijayrkn's answer, so closing it.

This does look like the best way to address the problem.
Is there a way to actually edit web.config directly then, or just transform it? Ideally I'd prefer to do that, but worst case I could add transforms for both Debug and Release to do the same thing.

You can also put a web.config file directly in the root directory of you application and it will be used for debug/release and added to published applications.

Ah! I had no idea that was supported. Thanks for suggesting that. For some reason, I had thought the web.config file needed to be created by the publish process. Now I see that I can add one and it's pre-populated with almost exactly the same content as you get from the default.
I did notice that the default created by Visual Studio doesn't include the <location path="." inheritInChildApplications="false"> element, but I was able to add that and the appropriate section for removing the offending "Access-Control-Allow-Origin" header.
Thanks everyone for your help and patience!

@vijayrkn the web.config template should include the <location path="." inheritInChildApplications="false"> by default.

In the latest version of VS, this section will be automatically added during publish

From: Ken Lyon notifications@github.com
Sent: Monday, November 5, 2018 2:41 PM
To: aspnet/AspNetCore AspNetCore@noreply.github.com
Cc: Vijay Ramakrishnan vramak@microsoft.com; Mention mention@noreply.github.com
Subject: Re: [aspnet/AspNetCore] Multiple Access-Control-Allow-Origin headers when using CORS in IIS (#3525)
Ah! I had no idea that was supported. Thanks for suggesting that. For some reason, I had thought the web.config file needed to be created by the publish process. Now I see that I can add one and it's pre-populated with almost exactly the same content as you get from the default.
I did notice that the default created by Visual Studio doesn't include the  element, but I was able to add that and the appropriate section for removing the offending "Access-Control-Allow-Origin" header.
Thanks everyone for your help and patience!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Faspnet%2FAspNetCore%2Fissues%2F3525%23issuecomment-436062709&data=02|01|vramak%40microsoft.com|1951313c37934863167208d6436fc317|72f988bf86f141af91ab2d7cd011db47|1|0|636770544628957914&sdata=hsm4ui8NRrc4cLZopZMCoEz%2FRJ6%2BB1pJG6XdDizZkEQ%3D&reserved=0, or mute the threadhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FADzBM4I9N26x4Tk1Rf1EAezWhgOqqHzxks5usL58gaJpZM4WiNoU&data=02|01|vramak%40microsoft.com|1951313c37934863167208d6436fc317|72f988bf86f141af91ab2d7cd011db47|1|0|636770544628957914&sdata=pZkvub3rX20ipda1rT%2BrJsaEaWmXKpThWx6nDHsYEYo%3D&reserved=0.

https://github.com/aspnet/websdk/blob/master/src/Publish/Microsoft.NET.Sdk.Publish.Tasks/WebConfigTransform.cs#L19

@vijayrkn If I publish when there is no web.config present in the project then the generated one does include the location element:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="dotnet" arguments=".\MyProject.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
    </system.webServer>
  </location>
</configuration>
<!--ProjectGuid: 06a3f362-aa7c-4b1a-8a2c-3b41b5c11715-->

However this process produces a different result:

Right-click the ASP.NET Core project in Visual Studio and choose Add > New item...
In the "Installed" list in the left column, expand ASP.NET Core and select Web.
In the list of templates, select Web Configuration File.
Click "Add".

This adds the following web.config file to the project:
<?xml version="1.0" encoding="utf-8"?>
<configuration>

  <!-- To customize the asp.net core module uncomment and edit the following section.
  For more info see https://go.microsoft.com/fwlink/?linkid=838655 -->
  <!--
  <system.webServer>
    <handlers>
      <remove name="aspNetCore"/>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
    </handlers>
    <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
  </system.webServer>
  -->

</configuration>

Note that the commented-out sample content does not include the location element, but is otherwise equivalent.
I don't know how much this matters or how high a priority it is to you, but it's the only discrepancy I see. If I want to be sure to produce the equivalent to the web.config that is created when I publish, I need to manually add the location element to the file that I add.

@kenlyon - That is correct. The location tag is only added during publish. The web.config item template does not have the location tag by default.
I will work with the Project system expert on my side to see if it makes sense to add this to the item template as well. Thank you for reporting this.
/cc @BillHiebert

authors: javiercn jkotalik kenlyon mkArtakMSFT pranavkm shirhatti vijayrkn


text:
CORS issue

Description of the problem:

Getting CORs issue when calling APIs:

Steps to reproduce (preferrably a link to a GitHub repo with a repro project)

https://microsoftit.visualstudio.com/OneITVSO/OneITVSO Team/_git/EUS-Col-ColPub-PublishAppsService
On running webpart with 'gulp serve --nobrowser', all api calls fail with CORS error.

The version of Microsoft.AspNetCore.App or Microsoft.AspNetCore.All
.NET Core 2.1.402

The output of dotnet --info

.NET Core SDK (reflecting any global.json):
Version:   2.1.402
Commit:    3599f217f4
Runtime Environment:
OS Name:     Windows
OS Version:  10.0.17134
OS Platform: Windows
RID:         win10-x64
Base Path:   C:\Program Files\dotnet\sdk\2.1.402\
Host (useful for support):
Version: 2.1.4
Commit:  85255dde3e
.NET Core SDKs installed:
2.1.202 [C:\Program Files\dotnet\sdk]
2.1.302 [C:\Program Files\dotnet\sdk]
2.1.401 [C:\Program Files\dotnet\sdk]
2.1.402 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
cc: @guardrex

The app you pointed to seems very large. Can you point to the specific folder that contains the web app that is refusing the CORS connection?

Here is the path to file in Service code where I set up the origin:
https://microsoftit.visualstudio.com/OneITVSO/OneITVSO Team/_git/EUS-Col-ColPub-PublishAppsService?path=%2FService%2FWebApi%2FService%2FHosts.WebApi%2FStartup.cs&version=GBmaster
Here is the path to file in Webpart code where API calls are failing because of the CORS issue mentioned above:
https://microsoftit.visualstudio.com/OneITVSO/OneITVSO Team/_git/EUS-Col-ColPub-PublishApps?path=%2FPublishApps%2Fsrc%2Fwebparts%2FpublishApps%2FComponents%2FSubmitAppForm%2Factions%2FActions.ts&version=GBmaster
Please let me know if you need any other details. Thanks!

@ManuelDev1810 can you try setting the log level to the most verbose level (https://docs.microsoft.com/en-us/aspnet/core/fundamentals/logging) and see what CorsService spits out? Might give some hints as to why the service decided a request did not qualify for CORS.

Hi. We're closing this issue as we have heard no response from you for some time now. If you have more details and are encountering this issue please add a new reply and re-open the issue.

authors: Eilon licypal mkArtakMSFT pranavkm


text:
Inconsistent usage of delegate types

Some examples:

https://github.com/aspnet/Hosting/blob/dev/src/Microsoft.AspNet.Hosting/Startup/StartupMethods.cs#L10
https://github.com/aspnet/HttpAbstractions/blob/dev/src/Microsoft.AspNet.Http/RequestDelegate.cs
https://github.com/aspnet/Hosting/blob/dev/src/Microsoft.AspNet.Hosting.Server.Interfaces/IServerFactory.cs#L15
https://github.com/aspnet/HttpAbstractions/blob/dev/src/Microsoft.AspNet.Http/IApplicationBuilder.cs#L17

Our public interfaces should be consistent (or have a good reason not to be).

So I take it this means we want to add delegates for everything?
public delegate Task ServerDelegate(IFeatureCollection features);
public delegate void ApplicationDelegate(IApplicationBuilder app);
public delegate RequestDelegate MiddlewareDelegate(RequestDelegate next);

/cc @lodejard to see his thoughts.

Not sure if this is worth the effort. The RequestDelegate type was only declared because it appears as a middleware constructor parameter in end-user code. I don't think any of the func or action these delegates represent appear in end-user code, so no reason to give them a named delegate type.

Only RequestDelegate remains doesn't sound like there's any interest in creating more delegates, closing this issue

authors: HaoK davidfowl lodejard

repo: aspnet/Hosting


text:
How to persist the login information after closing Broswer?

I want to persist the login information as long as possible once the user login my website,so the user don't need to login again when they reopened their Broswer,just like the github.com,when I once login the github,it can persist my information for many days,So I don't need to login again every day.Are there any methods can implment this feature with Identity?

Hi @kinshines, I think you'll get fast answer if you head out to www.stackoverflow.com for questions of this kind.
This repository to report possibles defects or missing feature. You might get an answer here, but it might take days or weeks (especially with the holidays).

thank you @MaximRouiller ,I think it is exactly the missing feature for persisting login information in ASP.NET Identity,and it is not simply a question which can be answered in www.stackoverflow.com.

authors: MaximRouiller kinshines

repo: aspnet/Identity


text:
Question : Server-Prerendering + passing data from asp.net mvc to angular component

What I am trying to do:  I would like to pass a value from my asp.net controller to my angular application where it can be used within the various angular components.
What I have done I referred to https://github.com/aspnet/JavaScriptServices/tree/dev/src/Microsoft.AspNetCore.SpaServices especially the sections on "Passing data from .NET code into JavaScript code" and "Passing data from server-side to client-side code". Following those examples, at this point, I have my data as a global value in window object. I can see it in console by doing window.data.
Issue :- However, the problem is that I would like to access this global variable within my components .ts file so that I can use it in my component. But since I am using Server side pre-rendering, the pre-rendering (correctly) throws an error if I try do to "window.data" in my .ts file.
The error is
Microsoft.AspNetCore.NodeServices:Error: ERROR ReferenceError: window is not defined
    at NavBarComponent.get [as loggedInDatabase] (C:\PROJECT\ars.net\ARS.Web\ClientApp\dist\main-server.js:22810:17)
    at Object.eval [as updateRenderer] (ng:///AppModule/NavBarComponent.ngfactory.js:150:23)
    at Object.updateRenderer (C:\PROJECT\ars.net\ARS.Web\ClientApp\dist\vendor.js:23356:70)
    at checkAndUpdateView (C:\PROJECT\ars.net\ARS.Web\ClientApp\dist\vendor.js:22885:14)
    at callViewAction (C:\PROJECT\ars.net\ARS.Web\ClientApp\dist\vendor.js:23243:21)
    at execComponentViewsAction (C:\PROJECT\ars.net\ARS.Web\ClientApp\dist\vendor.js:23175:13)
    at checkAndUpdateView (C:\PROJECT\ars.net\ARS.Web\ClientApp\dist\vendor.js:22886:5)
    at callViewAction (C:\PROJECT\ars.net\ARS.Web\ClientApp\dist\vendor.js:23243:21)
    at execComponentViewsAction (C:\PROJECT\ars.net\ARS.Web\ClientApp\dist\vendor.js:23175:13)
    at Object.checkAndUpdateView (C:\PROJECT\ars.net\ARS.Web\ClientApp\dist\vendor.js:22886:5)

Is there some workaround or maybe an alternate way to pass data from server to client?

You have to check and make sure you are on the client and not the server when checking window and document objects.  They don't exist on the server
import { PLATFORM_ID } from '@angular/core';
import { isPlatformBrowser, isPlatformServer } from '@angular/common';
constructor(@Inject(PLATFORM_ID) private platformId: Object) { ... }
ngOnInit() {
if (isPlatformBrowser(this.platformId)) {
// Client only code.
...
}
if (isPlatformServer(this.platformId)) {
// Server only code.
...
}
}

@jrmcdona  I knew it was something obvious I was missing. That is exactly what I was looking for. I remember reading about it earlier but just didnt come to mind. Thanks ever so much.

authors: jagmagh jrmcdona

repo: aspnet/JavaScriptServices


text:
Update comment for large screen media query

Just found this project today and so far it has been great to work with. Thanks for all the work put into making these Visual Studio templates.
When going through the CSS I noticed this typo for the desktop media query comments. This PR fixes the comments in the template css files replaces small with large where appropriate.

@BaylorRae,
Thanks for your contribution.
To ensure that the project team has proper rights to use your work, please complete the Contribution License Agreement at https://cla2.dotnetfoundation.org.
It will cover your contributions to all .NET Foundation-managed open source projects.
Thanks,
.NET Foundation Pull Request Bot

@BaylorRae, thanks for signing the contribution license agreement. We will now validate the agreement and then the pull request.
Thanks, .NET Foundation Pull Request Bot

These files were moved to aspnet/templating in 09317b83a86

authors: BaylorRae dnfclas


text:
In case of exception at startup, Kestrel still starts the website

When an exception is thrown in the configuration methods of the Startup class, I would expect the program to exit. However Kestrel continues and starts listening on the port, as if everything was normal.

This is an intended feature of Hosting to facilitate debugging in hosted environments. In development mode the error will be displayed in the browser.

Ok, that's all good if that's by design.

authors: Flavien Tratcher

repo: aspnet/KestrelHttpServer


text:
Request: Add metadata cache for jSDelivr and Unpkg providers

Based on https://github.com/aspnet/LibraryManager/issues/370#issuecomment-637953775 and https://github.com/aspnet/LibraryManager/issues/389#issuecomment-579920081, the library metadata for the Unpkg and JSDelivr providers is not yet cached.  This causes libman to make some requests on every restore using those providers, which should be unnecessary.  Addressing this may resolve some speed and reliability issues.
Is anyone currently working on this or is it up for grabs?

@RobJohnston I'm going to try to squeeze this in next week if I can, but feel free if you want to try it before then.
I think the cache behavior for the CDNJS provider also needs to be reviewed, in case it's throwing out the local cached copy even when a refresh request fails.  Due to how that caching works (IIRC all versions of a given library are in a single metadata file/request) we can't just rely on a local copy exclusively, we do need to try and refresh in case a newer version of the library has been released.

I only started to feel my way through the problem with jsDelivr using CDNJS as an example... haven't gotten too deep into it.
You are correct that all versions are in a single metadata file for CDNJS.  For example, https://api.cdnjs.com/libraries/jquery.  One challenge is that the other providers don't have such an endpoint in their APIs.
jsDelivr used to have a similar endpoint, but the advice with their new API is to query all the versions and then get the version that you want (see https://github.com/jsdelivr/data.jsdelivr.com/issues/7).  What UNPKG can provide is apparently still up for discussion (see https://github.com/mjackson/unpkg/issues/85).
I was thinking ahead when I made this issue... I thought the first step would be to get the caching done and then work on a resiliency strategy in a follow-up issue (likely with the cache being the fallback when all else fails).

Cache invalidation is hard

authors: RobJohnston jimmylewis pabrams

repo: aspnet/LibraryManager


text:
Reporting validation errors before calling operations

This PR fixes bug #300
We now call IEnumerable validationResults = await manifest.GetValidationResultsAsync() before all manifest operations.
We report validation errors if there are any, otherwise proceed with the operation and Log the operation results.
This PR also improves log messages so they are consistent and accurate.

    public static string GetSummaryHeaderString(OperationType operationType, string libraryId)

Remove this argument

Refers to: src/LibraryManager/Logging/LogMessageGenerator.cs:149 in f655583. [](commit_id = f655583b295eda90b4e493b6f72904d5833d72a7, deletion_comment = False)

authors: jodavis raquelsa


text:
Breakpoints are not hit in .cshtml files

Not sure if this is a Runtime, Razor, or MVC bug but let's start here since MVC does the compilation of Razor-generated files.  Using current VS / WTE builds (DP 22228.01 and 2014-10-29_b1886) with the latest origin/dev code, breakpoints in .cshtml files are not hit and are listed with an unusual tooltip.  Breaks on exceptions in the generated classes (e.g. NREs in the MVC sample at ~/Home/Post) have wildly incorrect locations.  No such issues exist with regular C# classes.
Ex. list of breakpoints:

Ex. tooltip message:

Problems occur with both IIS Express and Web Listener.  I was testing with CLR (not Core) configuration.
/cc @pranavkm since he was looking at this issue earlier.

I can hit breakpoints in some cases after my most recent VS re-installation but not when I follow our internal recommendations for VS setup.
If Debug / Options / General / "Require source files to exactly match the original version" is checked at the beginning of a debug session, breakpoints are hit in .cshtml files.  Otherwise they are not.  Changing this setting during a debug session does not change the behaviour.  (Note we've been recommending clearing this setting.)
Still unsure whether the problem exists in Razor, MVC, or VS...

Get together with @dougbu and @ToddGrun and get a consistent repro

@mayurid can your team get a consistent repro for this?

If Debug / Options / General / "Require source files to exactly match the original version" is checked at the beginning of a debug session, breakpoints are hit in .cshtml files. Otherwise they are not.

Yup, I'm seeing this behavior. Also seeing this if I click on the breakpoint and tick the "allow the source code to be different from the original version". Seem non-intuitive since you'd expect these flags the make the source file matching less restrictive and not more.
I'm using 14.0.22515.0 WPT with latest WTE.

This looks like a bug in VS. @mayurid @barrytang can you please investigate?

Opened a VS bug to track.

authors: barrytang dougbu pranavkm yishaigalatzer

repo: aspnet/Mvc


text:
Custom TagHelper that binds Scripts src attribute + asp-append-version="true" destroys script tag output

If you have the following TagHelper:
public class ScriptTagHelper : TagHelper
{
    public string Src { get; set; }
}

The following:
<script src="~/lib/jquery/dist/jquery.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.js" asp-append-version="true"></script>

Results in the following HTML:
<script></script>
<script src="/lib/bootstrap/dist/js/bootstrap.js?v=Cr6N6zNN4bp0OwTQOZ6Z66M2r-2dpy_EwKMCyZ-SOMg" src="/lib/bootstrap/dist/js/bootstrap.js"></script>

Is the "bug" in the existing ScriptTagHelper because it's doing something weird?

Is the "bug" in the existing ScriptTagHelper because it's doing something weird?

Possibly. I did not investigate thoroughly. The two TagHelpers  that are probably causing the issue are the UrlResolutionTagHelper and the ScriptTagHelper

Was this your own find, or is it from another discussion? That would help establish the priority.

@madskristensen discovered it.

authors: Eilon NTaylorMullen