Skip to content
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

fix(files): failsafe when executing actions methods #49685

Merged
merged 2 commits into from
Dec 11, 2024

Conversation

skjnldsv
Copy link
Member

@skjnldsv skjnldsv commented Dec 6, 2024

Should avoid breaking the files app entirely when an external app have written invalid code.

@skjnldsv skjnldsv added this to the Nextcloud 31 milestone Dec 6, 2024
@skjnldsv skjnldsv requested review from blizzz, juliusknorr, artonge and a team December 6, 2024 09:01
@skjnldsv skjnldsv self-assigned this Dec 6, 2024
@skjnldsv skjnldsv requested review from susnux and sorbaugh and removed request for a team December 6, 2024 09:01
@skjnldsv skjnldsv force-pushed the fix/fail-safe-files-actions branch from 1a3fca5 to 0d7e5ae Compare December 6, 2024 09:02
@skjnldsv skjnldsv changed the title fix-files): failsafe when executing actions methods fix(files): failsafe when executing actions methods Dec 6, 2024
@skjnldsv
Copy link
Member Author

skjnldsv commented Dec 6, 2024

/backport to stable30

@skjnldsv
Copy link
Member Author

skjnldsv commented Dec 6, 2024

/backport to stable29

Copy link
Member

@juliusknorr juliusknorr left a comment

Choose a reason for hiding this comment

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

Good idea 👍

@blizzz
Copy link
Member

blizzz commented Dec 6, 2024

/backport to stable28

susnux
susnux previously requested changes Dec 6, 2024
return action.displayName([this.source], this.currentView)
} catch (e) {
logger.error('Error while getting action display name', { action, e })
return ''
Copy link
Contributor

Choose a reason for hiding this comment

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

There should be at least some name, the empty string is not a good state also for ux.
Maybe use the ID.

if (title) return title
}
return action.displayName([this.source], this.currentView)
} catch (e) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
} catch (e) {
} catch (error) {

So the key in the logger context is meaningful

}
return action.displayName([this.source], this.currentView)
} catch (e) {
logger.error('Error while getting action display name', { action, e })
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
logger.error('Error while getting action display name', { action, e })
logger.error('Error while getting action display name', { action, error })

try {
return action?.inline?.(this.source, this.currentView)
} catch (e) {
logger.error('Error while checking if action is inline', { action, e })
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
logger.error('Error while checking if action is inline', { action, e })
logger.error('Error while checking if action is inline', { action, error })

let displayName = action.id
try {
displayName = action.displayName([this.source], this.currentView)
} catch (e) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
} catch (e) {
} catch (error) {

try {
displayName = action.displayName([this.source], this.currentView)
} catch (e) {
logger.error('Error while getting action display name', { action, e })
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
logger.error('Error while getting action display name', { action, e })
logger.error('Error while getting action display name', { action, error })

Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
@skjnldsv skjnldsv dismissed susnux’s stale review December 11, 2024 07:54

Addressed 🫶

@skjnldsv skjnldsv force-pushed the fix/fail-safe-files-actions branch from 0d7e5ae to 4470dd6 Compare December 11, 2024 07:55
@skjnldsv skjnldsv enabled auto-merge December 11, 2024 07:57
@skjnldsv
Copy link
Member Author

/compile

Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
@skjnldsv skjnldsv merged commit 91a83b6 into master Dec 11, 2024
120 checks passed
@skjnldsv skjnldsv deleted the fix/fail-safe-files-actions branch December 11, 2024 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants