Skip to content

add BUILD_METADATA fallback when parsing - #2503

Merged
ukutaht merged 1 commit into
plausible:masterfrom
ruslandoga:fallback-build-info
Dec 5, 2022
Merged

add BUILD_METADATA fallback when parsing#2503
ukutaht merged 1 commit into
plausible:masterfrom
ruslandoga:fallback-build-info

Conversation

@ruslandoga

@ruslandoga ruslandoga commented Dec 5, 2022

Copy link
Copy Markdown
Contributor

Changes

This PR adds a fallback to empty build metadata when BUILD_METADATA contains invalid JSON.

Example warning log for BUILD_METADATA={...}:

20:57:57.872 [warning] failed to parse $BUILD_METADATA, reason: ** (Jason.DecodeError) unexpected byte at position 1: 0x2E (".")

Fixes #2491

Tests

  • This PR does not require tests

Changelog

  • Entry has been added to changelog

Documentation

  • This change does not need a documentation update

Dark mode

  • This PR does not change the UI

@ruslandoga
ruslandoga requested review from aerosol and ukutaht December 5, 2022 14:00
Comment thread config/runtime.exs
{:error, error} ->
error = Exception.format(:error, error)
Logger.warn("failed to parse $BUILD_METADATA, reason: " <> error)
_fallback = %{}

@ruslandoga ruslandoga Dec 5, 2022

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Should empty %{} fallback be mentioned in the warning?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Should $BUILD_METADATA contents be added to the warning?

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.

Yes to both :)

@ruslandoga ruslandoga Dec 5, 2022

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Screenshot 2022-12-05 at 21 46 00

I added whitespace to make it stand out. Not sure if it makes sense though...

@ruslandoga ruslandoga Dec 5, 2022

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In case the image doesn't load, here's the text version:

21:44:31.793 [warning] failed to parse $BUILD_METADATA: ** (Jason.DecodeError) unexpected byte at position 38: 0x70 ("p")

    $BUILD_METADATA is set to {"tags":["plausible/analytics:v1.5.0",plausible/analytics:v1.5,plausible/analytics:v1,"plausible/analytics:latest"],"labels":{"org.opencontainers.image.title":"analytics","org.opencontainers.image.description":"Simple, open-source, lightweight (< 1 KB) and privacy-friendly web analytics alternative to Google Analytics.","org.opencontainers.image.url":"https://github.com/plausible/analytics","org.opencontainers.image.source":"https://github.com/plausible/analytics","org.opencontainers.image.version":"v1.5.0","org.opencontainers.image.created":"2022-12-02T15:45:09.831Z","org.opencontainers.image.revision":"f9ab2650b3192021d5808cc8f20064aa8af543f4","org.opencontainers.image.licenses":"AGPL-3.0"}}
 
21:44:31.796 [warning] falling back to empty build metadata, as if $BUILD_METADATA was set to {}

@bundlemon

bundlemon Bot commented Dec 5, 2022

Copy link
Copy Markdown

BundleMon

Unchanged files (7)
Status Path Size Limits
static/css/app.css
515.19KB -
static/js/dashboard.js
297.98KB -
static/js/app.js
12.13KB -
static/js/embed.host.js
5.58KB -
static/js/embed.content.js
5.06KB -
tracker/js/plausible.js
748B -
static/js/applyTheme.js
314B -

No change in files bundle size

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

@ruslandoga
ruslandoga force-pushed the fallback-build-info branch 2 times, most recently from 6c24f99 to 68b15cf Compare December 5, 2022 14:43
@ukutaht
ukutaht merged commit 138e7c0 into plausible:master Dec 5, 2022
@ruslandoga
ruslandoga deleted the fallback-build-info branch December 6, 2022 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crash on startup after docker image update

2 participants