Skip to content

Commit 1353914

Browse files
authored
Merge pull request #1394 from nagilson/nagilson-proxy-reg
Dont let proxy check fail if registry access is disabled
2 parents f1cc1fd + e52c05a commit 1353914

File tree

10 files changed

+73
-37
lines changed

10 files changed

+73
-37
lines changed

azure-pipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ stages:
9494
addToPath: true
9595
architecture: 'x64'
9696
- task: PythonScript@0
97+
continueOnError: true
9798
inputs:
9899
scriptSource: 'filePath'
99100
scriptPath: 'dependency-verifier.py'
100101
arguments: '$(System.PullRequest.TargetBranch)'
101-
failOnStderr: true
102102
##### Package and Publish #####
103103
- job: Package
104104
displayName: 'Package and Publish'

dependency-verifier.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ def main():
1414

1515
def VerifyDependencies(targetBranch):
1616
"""Enumerate through all changed files to check diffs."""
17-
# origin/ requires origin/ to be up to date.
17+
# origin/ requires origin/ to be up to date.
1818
changedFiles = [Path(path) for path in subprocess.getoutput(f"git diff --name-only origin/{targetBranch}..").splitlines()]
1919
npmLockFile = "package-lock.json"
20-
20+
2121
for file in changedFiles:
2222
fileName = os.path.basename(os.path.realpath(file))
2323
if fileName == npmLockFile:
@@ -48,7 +48,7 @@ def GetYarnDependencyUpdates(yarnLockDiffLines):
4848
return dependencies
4949

5050
def GetUnmatchedDiffs(yarnDiff, npmDiff):
51-
"""Returns [] if dependency updates are reflected in both diffs, elsewise the dependencies out of sync."""
51+
"""Returns [] if dependency updates are reflected in both diffs, else the dependencies out of sync."""
5252
# v Remove + or - from diff and additional git diff context lines
5353
yarnDeps = GetYarnDependencyUpdates([line[1:] for line in yarnDiff.splitlines() if line.startswith("+") or line.startswith("-")])
5454
npmDeps = GetNpmDependencyUpdates([line[1:] for line in npmDiff.splitlines() if line.startswith("+") or line.startswith("-")])
@@ -61,11 +61,11 @@ def GetUnmatchedDiffs(yarnDiff, npmDiff):
6161
return outOfSyncDependencies
6262

6363
def NpmChangesMirrorYarnChanges(changedFiles, packageLockPath, targetBranch):
64-
"""Returns successfully if yarn.lock matches packagelock changes, if not, throws exit code"""
64+
"""Returns successfully if yarn.lock matches package lock changes, if not, throws exit code"""
6565
yarnLockFile = "yarn.lock"
6666
yarnLockPath = Path(os.path.join(os.path.dirname(packageLockPath), yarnLockFile))
6767
outOfDateYarnLocks = []
68-
68+
6969
if yarnLockPath in changedFiles:
7070
yarnDiff = subprocess.getoutput(f"git diff origin/{targetBranch}.. -- {str(yarnLockPath)}")
7171
npmDiff = subprocess.getoutput(f"git diff origin/{targetBranch}.. -- {packageLockPath}")
@@ -77,9 +77,13 @@ def NpmChangesMirrorYarnChanges(changedFiles, packageLockPath, targetBranch):
7777
else:
7878
outOfDateYarnLocks.append(yarnLockPath)
7979
if(outOfDateYarnLocks != []):
80-
sys.exit(f"The yarn.lock and package-lock appear to be out of sync with the changes made after {targetBranch}. Update by first using npm to push to the registry, doing npm install package@version. Then, do yarn add package@version for {outOfDateYarnLocks}. During the yarn add process, you may need to npm install specific dependencies that yarn will flag to allow yarn to proceed. You may consider (yarn import). Note this tool will list dependencies of packages, but you should try adding just the main package first. If you can confirm the new changes are in sync, then you may ignore this failure.")
80+
sys.exit(f"""{outOfDateYarnLocks} may be out of sync with node.
81+
82+
The yarn.lock and package-lock appear to be out of sync with the changes made after {targetBranch}.
83+
Update by first using npm to push to the registry, doing npm install package@version. Then, do yarn add package@version for each primary package. During the yarn add process, you may need to npm install specific dependencies that yarn will flag to allow yarn to proceed. You may consider (yarn import). Note this tool will list dependencies of packages, but you should try adding just the main package first.
84+
If you can confirm the new changes are in sync, then you may ignore this failure.""")
8185
else:
8286
return 0 # OK, status here is not used
83-
87+
8488
if __name__ == "__main__":
8589
main()

sample/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sample/yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1277,7 +1277,7 @@
12771277

12781278
"vscode-dotnet-runtime@file:../vscode-dotnet-runtime-extension":
12791279
"resolved" "file:../vscode-dotnet-runtime-extension"
1280-
"version" "1.7.3"
1280+
"version" "1.7.4"
12811281
dependencies:
12821282
"axios" "^1.3.4"
12831283
"axios-cache-interceptor" "^1.0.1"

vscode-dotnet-runtime-extension/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning].
77

88
## [Unreleased]
99

10+
## [1.7.4] - 2023-08-24
11+
12+
Install using node.arch() instead of environment variable architecture from root terminal to prevent mismatching shell architecture with vs code architecture.
13+
Don't read registry for proxy lookup if permission is unavailable to do so, requires manual proxy setting in this case.
14+
1015
## [1.7.3] - 2023-08-24
1116

1217
Fixes an issue where install script files could have race conditions by introducing file locking mechanisms.

vscode-dotnet-runtime-extension/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vscode-dotnet-runtime-extension/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"description": "This extension installs and manages different versions of the .NET Runtime.",
1414
"appInsightsKey": "02dc18e0-7494-43b2-b2a3-18ada5fcb522",
1515
"icon": "images/dotnetIcon.png",
16-
"version": "1.7.3",
16+
"version": "1.7.4",
1717
"publisher": "ms-dotnettools",
1818
"engines": {
1919
"vscode": "^1.72.0"

vscode-dotnet-runtime-library/src/EventStream/EventStreamEvents.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,25 @@ export abstract class DotnetAcquisitionError extends IEvent {
8080
public getProperties(telemetry = false): { [key: string]: string } | undefined {
8181
return {ErrorName : this.error.name,
8282
ErrorMessage : this.error.message,
83-
StackTrace : this.error.stack ? this.error.stack : ''};
83+
StackTrace : this.error.stack ? TelemetryUtilities.HashAllPaths(this.error.stack) : ''};
84+
}
85+
}
86+
87+
88+
export class SuppressedAcquisitionError extends IEvent {
89+
public readonly eventName = 'SuppressedAcquisitionError';
90+
public readonly type = EventType.SuppressedAcquisitionError;
91+
92+
constructor(public readonly error: Error, public readonly supplementalMessage : string) {
93+
super();
94+
}
95+
96+
public getProperties(telemetry = false): { [key: string]: string } | undefined {
97+
return {
98+
SupplementMessage : this.supplementalMessage,
99+
ErrorName : this.error.name,
100+
ErrorMessage : telemetry ? 'redacted' : TelemetryUtilities.HashAllPaths(this.error.message),
101+
StackTrace : telemetry ? 'redacted' : (this.error.stack ? TelemetryUtilities.HashAllPaths(this.error.stack) : '')};
84102
}
85103
}
86104

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
/*---------------------------------------------------------------------------------------------
2-
* Copyright (c) Microsoft Corporation. All rights reserved.
3-
* Licensed under the MIT License. See License.txt in the project root for license information.
4-
*--------------------------------------------------------------------------------------------*/
5-
6-
export enum EventType {
7-
DotnetAcquisitionStart,
8-
DotnetSDKAcquisitionStart,
9-
DotnetRuntimeAcquisitionStart,
10-
DotnetAcquisitionCompleted,
11-
DotnetAcquisitionError,
12-
DotnetAcquisitionSuccessEvent,
13-
DotnetAcquisitionMessage,
14-
DotnetAcquisitionTest,
15-
DotnetAcquisitionAlreadyInstalled,
16-
DotnetAcquisitionInProgress
17-
}
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
export enum EventType {
7+
DotnetAcquisitionStart,
8+
DotnetSDKAcquisitionStart,
9+
DotnetRuntimeAcquisitionStart,
10+
DotnetAcquisitionCompleted,
11+
DotnetAcquisitionError,
12+
DotnetAcquisitionSuccessEvent,
13+
DotnetAcquisitionMessage,
14+
DotnetAcquisitionTest,
15+
DotnetAcquisitionAlreadyInstalled,
16+
DotnetAcquisitionInProgress,
17+
SuppressedAcquisitionError
18+
}

vscode-dotnet-runtime-library/src/Utils/WebRequestWorker.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ import { HttpsProxyAgent } from 'https-proxy-agent';
88
import { getProxySettings } from 'get-proxy-settings';
99
import { AxiosCacheInstance, buildStorage, setupCache, StorageValue } from 'axios-cache-interceptor';
1010
import { IEventStream } from '../EventStream/EventStream';
11-
import { WebRequestError, WebRequestSent } from '../EventStream/EventStreamEvents';
11+
import { SuppressedAcquisitionError, WebRequestError, WebRequestSent } from '../EventStream/EventStreamEvents';
1212
import { IExtensionState } from '../IExtensionState';
1313
import { Debugging } from '../Utils/Debugging';
14+
/* tslint:disable:no-any */
1415

1516
/*
1617
This wraps the VSCode memento state blob into an axios-cache-interceptor-compatible Storage.
@@ -149,14 +150,21 @@ export class WebRequestWorker
149150
{
150151
if(!this.proxyEnabled())
151152
{
152-
const autoDetectProxies = await getProxySettings();
153-
if(autoDetectProxies?.https)
153+
try
154154
{
155-
this.proxy = autoDetectProxies.https.toString();
155+
const autoDetectProxies = await getProxySettings();
156+
if(autoDetectProxies?.https)
157+
{
158+
this.proxy = autoDetectProxies.https.toString();
159+
}
160+
else if(autoDetectProxies?.http)
161+
{
162+
this.proxy = autoDetectProxies.http.toString();
163+
}
156164
}
157-
else if(autoDetectProxies?.http)
165+
catch(error : any)
158166
{
159-
this.proxy = autoDetectProxies.http.toString();
167+
this.eventStream.post(new SuppressedAcquisitionError(error, `The proxy lookup failed, most likely due to limited registry access. Skipping automatic proxy lookup.`));
160168
}
161169
}
162170
if(this.proxyEnabled())

0 commit comments

Comments
 (0)