Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion harmony/pushy/src/main/ets/PushyFileJSBundleProvider.ets
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ export class PushyFileJSBundleProvider extends JSBundleProvider {
}

getURL(): string {
return this.updateContext.getBundleUrl();
const path = this.updateContext.getBundleUrl();
if (path && !path.startsWith('file://')) {
return 'file://' + path;
}
return path;
}
Comment on lines 18 to 24

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

getURL() can return undefined violating its string return type.

this.updateContext.getBundleUrl() may return undefined (or empty string), and when path is falsy, the method falls through to return path (line 23), returning undefined despite the string type annotation. This could cause runtime issues for consumers expecting a valid URL string.

Add explicit handling for the undefined/empty case, or adjust the return type to string | undefined if that's the intended contract.

getURL(): string | undefined {
    const path = this.updateContext.getBundleUrl();
    if (!path) {
      return undefined;
    }
    if (!path.startsWith('file://')) {
      return 'file://' + path;
    }
    return path;
}

Or if empty path should never happen, throw or return empty string with a warning.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@harmony/pushy/src/main/ets/PushyFileJSBundleProvider.ets` around lines 18 -
24, getURL() may return undefined despite being declared as returning string,
because PushyFileJSBundleProvider.getURL falls through to return path when
updateContext.getBundleUrl() is empty or undefined. Update getURL() to
explicitly handle the falsy path case by returning a valid string, or change the
method signature to string | undefined if that is the intended contract, while
keeping the existing file:// prefix logic intact.


async getBundle(): Promise<FileJSBundle> {
Expand Down