-
Notifications
You must be signed in to change notification settings - Fork 142
Fix missing version in extensionBundle causing Python timer trigger runtime error #4602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Copilot
wants to merge
4
commits into
main
Choose a base branch
from
copilot/fix-4594
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
1275387
Initial plan
Copilot d1224f9
Initial analysis of extensionBundle version issue
Copilot 76492bc
Fix extensionBundle missing version issue in verifyExtensionBundle.ts
Copilot 5e5ee1a
Improve extensionBundle fix to handle missing id edge case
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import * as assert from 'assert'; | ||
import { IHostJsonV2, bundleFeedUtils } from '../extension.bundle'; | ||
|
||
suite('ExtensionBundle Version Fix Tests', () => { | ||
test('addDefaultBundle fixes incomplete extensionBundle missing version', async () => { | ||
// Simulate the problematic host.json from the issue | ||
const incompleteHostJson: IHostJsonV2 = { | ||
version: '2.0', | ||
logging: { | ||
applicationInsights: { | ||
samplingSettings: { | ||
isEnabled: true, | ||
excludedTypes: 'Request' | ||
} | ||
} | ||
}, | ||
extensionBundle: { | ||
id: 'Microsoft.Azure.Functions.ExtensionBundle' | ||
// Missing version property - this is the bug! | ||
} | ||
}; | ||
|
||
const mockContext = { | ||
telemetry: { properties: {} } | ||
} as any; | ||
|
||
// Verify the bundle is incomplete before fix | ||
assert.ok(incompleteHostJson.extensionBundle, 'extensionBundle should exist'); | ||
assert.ok(incompleteHostJson.extensionBundle.id, 'extensionBundle should have id'); | ||
assert.ok(!incompleteHostJson.extensionBundle.version, 'extensionBundle should be missing version (this is the bug)'); | ||
|
||
// Apply the fix | ||
await bundleFeedUtils.addDefaultBundle(mockContext, incompleteHostJson); | ||
|
||
// Verify the bundle is now complete | ||
assert.ok(incompleteHostJson.extensionBundle, 'extensionBundle should still exist'); | ||
assert.strictEqual(incompleteHostJson.extensionBundle.id, bundleFeedUtils.defaultBundleId); | ||
assert.ok(incompleteHostJson.extensionBundle.version, 'extensionBundle should now have version'); | ||
assert.ok(incompleteHostJson.extensionBundle.version.includes('*'), 'version should be a range pattern'); | ||
}); | ||
|
||
test('verifyExtensionBundle logic should detect incomplete bundle', () => { | ||
// Test the logic that was fixed in verifyExtensionBundle.ts | ||
|
||
// Case 1: No extensionBundle at all | ||
const hostJsonNoBundle: IHostJsonV2 = { version: '2.0' }; | ||
const shouldFixNoBundle = !hostJsonNoBundle.extensionBundle || | ||
!hostJsonNoBundle.extensionBundle?.id || | ||
!hostJsonNoBundle.extensionBundle?.version; | ||
assert.ok(shouldFixNoBundle, 'Should fix when no extensionBundle exists'); | ||
|
||
// Case 2: extensionBundle exists but missing version (the main bug case) | ||
const hostJsonIncompleteBundle: IHostJsonV2 = { | ||
version: '2.0', | ||
extensionBundle: { | ||
id: 'Microsoft.Azure.Functions.ExtensionBundle' | ||
// No version! | ||
} | ||
}; | ||
const shouldFixIncomplete = !hostJsonIncompleteBundle.extensionBundle || | ||
!hostJsonIncompleteBundle.extensionBundle.id || | ||
!hostJsonIncompleteBundle.extensionBundle.version; | ||
assert.ok(shouldFixIncomplete, 'Should fix when extensionBundle exists but version is missing'); | ||
|
||
// Case 3: extensionBundle exists but missing id (edge case) | ||
const hostJsonMissingId: IHostJsonV2 = { | ||
version: '2.0', | ||
extensionBundle: { | ||
version: '[1.*, 2.0.0)' | ||
// No id! | ||
} | ||
}; | ||
const shouldFixMissingId = !hostJsonMissingId.extensionBundle || | ||
!hostJsonMissingId.extensionBundle.id || | ||
!hostJsonMissingId.extensionBundle.version; | ||
assert.ok(shouldFixMissingId, 'Should fix when extensionBundle exists but id is missing'); | ||
|
||
// Case 4: Complete extensionBundle | ||
const hostJsonComplete: IHostJsonV2 = { | ||
version: '2.0', | ||
extensionBundle: { | ||
id: 'Microsoft.Azure.Functions.ExtensionBundle', | ||
version: '[1.*, 2.0.0)' | ||
} | ||
}; | ||
const shouldFixComplete = !hostJsonComplete.extensionBundle || | ||
!hostJsonComplete.extensionBundle.id || | ||
!hostJsonComplete.extensionBundle.version; | ||
assert.ok(!shouldFixComplete, 'Should NOT fix when extensionBundle is complete'); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should test against
[4.*, 5.0.0)
as the default