Electron100 / butane

An ORM for Rust with a focus on simplicity and on writing Rust, not SQL
Apache License 2.0
83 stars 11 forks source link

Intermittent test failure: SerdeJson(Error("trailing characters", line: 1, column: 42)) #162

Open jayvdb opened 8 months ago

jayvdb commented 8 months ago

Not sure why this occurred, but it doesnt appear related to the PR

https://github.com/Electron100/butane/actions/runs/6779692955/attempts/1?pr=161

Rerunning the workflow succeeded.

Compiling butane_codegen v0.6.1 (/home/runner/work/butane/butane/butane_codegen)
failed to read types "/home/runner/work/butane/butane/butane/.butane/migrations/current/types.json"
error: proc-macro derive panicked
 --> butane/tests/custom_enum_derived.rs:9:39
  |
9 | #[derive(PartialEq, Eq, Debug, Clone, FieldType)]
  |                                       ^^^^^^^^^
  |
  = help: message: called `Result::unwrap()` on an `Err` value: SerdeJson(Error("trailing characters", line: 1, column: 42))

error[E0277]: the trait bound `Whatsit: ToSql` is not satisfied
  --> butane/tests/custom_enum_derived.rs:16:1
   |
16 | #[model]
   | ^^^^^^^^ the trait `ToSql` is not implemented for `Whatsit`
   |
   = help: the following other types implement trait `ToSql`:
             bool
             i8
             i16
             i32
             i[64](https://github.com/Electron100/butane/actions/runs/6779692955/job/18427146440?pr=161#step:10:65)
             u8
             u16
             u32
           and 16 others
   = note: required for `SqlVal` to implement `From<Whatsit>`
   = note: required for `Whatsit` to implement `Into<SqlVal>`
note: required by a bound in `FieldExpr`
  --> /home/runner/work/butane/butane/butane_core/src/query/fieldexpr.rs:43:8
   |
41 | pub struct FieldExpr<T>
   |            --------- required by a bound in this struct
42 | where
43 |     T: Into<SqlVal>,
   |        ^^^^^^^^^^^^ required by this bound in `FieldExpr`
   = note: this error originates in the attribute macro `model` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E02[77](https://github.com/Electron100/butane/actions/runs/6779692955/job/18427146440?pr=161#step:10:78)`.
error: could not compile `butane` (test "custom_enum_derived") due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
Error: Process completed with exit code 101.
jayvdb commented 5 months ago

Maybe there isnt enough locking around writing and reading types.json ? But it is odd that it is always around byte 41/42.

This CI looks very similar https://github.com/Electron100/butane/actions/runs/7513662527/job/20455666845?pr=170 , and it was fixed on the second run.

failed to read types "/home/runner/work/butane/butane/butane/.butane/migrations/current/types.json"
error: proc-macro derive panicked
   --> butane/tests/json.rs:234:39
    |
234 | #[derive(PartialEq, Eq, Debug, Clone, FieldType, Serialize, Deserialize)]
    |                                       ^^^^^^^^^
    |
    = help: message: called `Result::unwrap()` on an `Err` value: SerdeJson(Error("trailing characters", line: 1, column: 42))

And I saw it locally, and then the tests passed when I ran them again.

failed to read types "/home/jayvdb/rust/butane/butane/.butane/migrations/current/types.json"
error: custom attribute panicked
  --> butane/tests/common/blog.rs:86:1
   |
86 | #[model]
   | ^^^^^^^^
   |
   = help: message: called `Result::unwrap()` on an `Err` value: SerdeJson(Error("trailing characters", line: 1, column: 41))
jayvdb commented 5 months ago

One of our team had this occur repeatedly until they deleted their ~/.cargo/registry

jayvdb commented 3 months ago

still occurring https://github.com/Electron100/butane/actions/runs/8320446441/job/22765175487 https://github.com/Electron100/butane/actions/runs/8090113053/job/22107086668

Compiling butane_codegen v0.6.1 (/home/runner/work/butane/butane/butane_codegen)
failed to read types "/home/runner/work/butane/butane/butane/.butane/migrations/current/types.json"
error: custom attribute panicked
  --> butane/tests/common/blog.rs:86:1
   |
86 | #[model]
   | ^^^^^^^^
   |
   = help: message: called `Result::unwrap()` on an `Err` value: SerdeJson(Error("trailing characters", line: 2, column: 1))

failed to read types "/home/runner/work/butane/butane/butane/.butane/migrations/current/types.json"
error: custom attribute panicked
  --> butane/tests/many.rs:27:1
   |
27 | #[model]
   | ^^^^^^^^
   |
   = help: message: called `Result::unwrap()` on an `Err` value: SerdeJson(Error("trailing characters", line: 2, column: 1))

error[E0432]: unresolved import `common::blog::Tag`
 --> butane/tests/many.rs:9:44
  |
9 | use common::blog::{create_tag, Blog, Post, Tag};
  |                                            ^^^ no `Tag` in `common::blog`
  |
  = help: consider importing one of these items instead:
          serde::__private::de::TagContentOtherField::Tag
          serde::__private::de::TagOrContentField::Tag

error[E0412]: cannot find type `Tag` in this scope
  --> butane/tests/common/blog.rs:36:20
   |
36 |     pub tags: Many<Tag>,
   |                    ^^^ not found in this scope
   |
help: there is an enum variant `serde::__private::de::TagContentOtherField::Tag` and 1 other; try using the variant's enum
   |
36 |     pub tags: Many<serde::__private::de::TagContentOtherField>,
   |                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
36 |     pub tags: Many<serde::__private::de::TagOrContentField>,
   |                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
help: you might be missing a type parameter
   |
29 | pub struct Post<Tag> {
   |                +++++

error[E0412]: cannot find type `Tag` in this scope
  --> butane/tests/common/blog.rs:36:20
   |
36 |     pub tags: Many<Tag>,
   |                    ^^^ not found in this scope
   |
help: there is an enum variant `serde::__private::de::TagContentOtherField::Tag` and 1 other; try using the variant's enum
   |
36 |     pub tags: Many<serde::__private::de::TagContentOtherField>,
   |                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
36 |     pub tags: Many<serde::__private::de::TagOrContentField>,
   |                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
help: you might be missing a type parameter
   |
28 | #[cfg_attr(feature = "fake", derive(Dummy<Tag>))]
   |                                          +++++

error[E0412]: cannot find type `Tag` in this scope
  --> butane/tests/common/blog.rs:36:20
   |
36 |     pub tags: Many<Tag>,
   |                    ^^^ not found in this scope
   |
help: there is an enum variant `serde::__private::de::TagContentOtherField::Tag` and 1 other; try using the variant's enum
   |
36 |     pub tags: Many<serde::__private::de::TagContentOtherField>,
   |                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
36 |     pub tags: Many<serde::__private::de::TagOrContentField>,
   |                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

error[E0412]: cannot find type `Tag` in this scope
  --> butane/tests/common/blog.rs:94:6
   |
94 | impl Tag {
   |      ^^^ not found in this scope
   |
help: there is an enum variant `serde::__private::de::TagContentOtherField::Tag` and 1 other; try using the variant's enum
   |
94 | impl serde::__private::de::TagContentOtherField {
   |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
94 | impl serde::__private::de::TagOrContentField {
   |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

error[E0422]: cannot find struct, variant or union type `Tag` in this scope
  --> butane/tests/common/blog.rs:96:9
   |
96 |         Tag {
   |         ^^^ not found in this scope
   |
help: consider importing one of these items
   |
1  + use serde::__private::de::TagContentOtherField::Tag;
   |
1  + use serde::__private::de::TagOrContentField::Tag;
   |

error[E0412]: cannot find type `Tag` in this scope
   --> butane/tests/common/blog.rs:102:[53](https://github.com/Electron100/butane/actions/runs/8090113053/job/22107086668#step:11:54)
    |
102 | pub fn create_tag(conn: &Connection, name: &str) -> Tag {
    |                                                     ^^^ not found in this scope
    |
help: there is an enum variant `serde::__private::de::TagContentOtherField::Tag` and 1 other; try using the variant's enum
    |
102 | pub fn create_tag(conn: &Connection, name: &str) -> serde::__private::de::TagContentOtherField {
    |                                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
102 | pub fn create_tag(conn: &Connection, name: &str) -> serde::__private::de::TagOrContentField {
    |                                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

error[E0412]: cannot find type `RenamedAutoPkWithMany` in this scope
  --> butane/tests/many.rs:34:6
   |
11 | #[model]
   | -------- similarly named struct `AutoPkWithMany` defined here
...
34 | impl RenamedAutoPkWithMany {
   |      ^^^^^^^^^^^^^^^^^^^^^ help: a struct with a similar name exists: `AutoPkWithMany`

error[E0422]: cannot find struct, variant or union type `RenamedAutoPkWithMany` in this scope
  --> butane/tests/many.rs:36:9
   |
11 | #[model]
   | -------- similarly named struct `AutoPkWithMany` defined here
...
36 |         RenamedAutoPkWithMany {
   |         ^^^^^^^^^^^^^^^^^^^^^ help: a struct with a similar name exists: `AutoPkWithMany`

error[E0433]: failed to resolve: use of undeclared type `Tag`
   --> butane/tests/common/blog.rs:103:19
    |
103 |     let mut tag = Tag::new(name);
    |                   ^^^ use of undeclared type `Tag`
    |
help: there is an enum variant `serde::__private::de::TagContentOtherField::Tag` and 1 other; try using the variant's enum
    |
103 |     let mut tag = serde::__private::de::TagContentOtherField(name);
    |                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
103 |     let mut tag = serde::__private::de::TagOrContentField(name);
    |                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

error[E0433]: failed to resolve: use of undeclared type `RenamedAutoPkWithMany`
   --> butane/tests/many.rs:201:19
    |
201 |     let mut obj = RenamedAutoPkWithMany::new();
    |                   ^^^^^^^^^^^^^^^^^^^^^
    |                   |
    |                   use of undeclared type `RenamedAutoPkWithMany`
    |                   help: a struct with a similar name exists: `AutoPkWithMany`

error[E0433]: failed to resolve: use of undeclared type `RenamedAutoPkWithMany`
   --> butane/tests/many.rs:206:15
    |
206 |     let obj = RenamedAutoPkWithMany::get(&conn, obj.id).unwrap();
    |               ^^^^^^^^^^^^^^^^^^^^^
    |               |
    |               use of undeclared type `RenamedAutoPkWithMany`
    |               help: a struct with a similar name exists: `AutoPkWithMany`

Some errors have detailed explanations: E0412, E0422, E0432, E0433.
For more information about an error, try `rustc --explain E0412`.
error: could not compile `butane` (test "many") due to 15 previous errors
warning: build failed, waiting for other jobs to finish...
jayvdb commented 3 months ago

On Windows https://github.com/Electron100/butane/actions/runs/8494192148/job/23269030123

cd butane && cargo +stable test --all-features
 Downloading crates ...
  Downloaded strsim v0.7.0
  Downloaded unicode-xid v0.1.0
  Downloaded syn v0.[15](https://github.com/Electron100/butane/actions/runs/8494515035/job/23269791025?pr=232#step:16:16).44
  Downloaded quote v0.6.13
  Downloaded proc-macro2 v0.4.30
  Downloaded exec_time v0.1.4
  Downloaded darling_macro v0.9.0
  Downloaded darling_core v0.9.0
  Downloaded darling v0.9.0
   Compiling ident_case v1.0.1
   Compiling fnv v1.0.7
   Compiling serde_json v1.0.114
   Compiling proc-macro2 v0.4.30
   Compiling strsim v0.10.0
   Compiling unicode-xid v0.1.0
   Compiling syn v0.15.44
   Compiling darling_core v0.20.8
   Compiling atomic v0.5.3
   Compiling sha1_smol v1.0.0
   Compiling quote v0.6.13
   Compiling postgres-types v0.2.6
   Compiling tokio-postgres v0.7.10
   Compiling uuid v1.7.0
   Compiling strsim v0.7.0
   Compiling rusqlite v0.31.0
   Compiling postgres v0.19.7
   Compiling darling_core v0.9.0
   Compiling darling_macro v0.20.8
   Compiling darling v0.20.8
   Compiling dummy v0.7.0
   Compiling fake v2.9.2
   Compiling postgres-native-tls v0.5.0
   Compiling butane_core v0.6.1 (D:\a\butane\butane\butane_core)
   Compiling darling_macro v0.9.0
   Compiling darling v0.9.0
   Compiling exec_time v0.1.4
   Compiling butane_test_helper v0.6.1 (D:\a\butane\butane\butane_test_helper)
   Compiling butane v0.6.1 (D:\a\butane\butane\butane)
failed to read types "D:\\a\\butane\\butane\\butane\\.butane\\migrations\\current\\types.json"
error: proc-macro derive panicked
Error:  --> butane\tests\custom_enum_derived.rs:8:39
  |
8 | #[derive(PartialEq, Eq, Debug, Clone, FieldType)]
  |                                       ^^^^^^^^^
  |
  = help: message: called `Result::unwrap()` on an `Err` value: SerdeJson(Error("EOF while parsing a value", line: 1, column: 0))

error[E0277]: the trait bound `Whatsit: ToSql` is not satisfied
Error:   --> butane\tests\custom_enum_derived.rs:15:1
   |
15 | #[model]
   | ^^^^^^^^ the trait `ToSql` is not implemented for `Whatsit`, which is required by `Whatsit: Into<SqlVal>`
   |
   = help: the following other types implement trait `ToSql`:
             bool
             i8
             i[16](https://github.com/Electron100/butane/actions/runs/8494515035/job/23269791025?pr=232#step:16:17)
             i32
             i64
             u8
             u16
             u32
           and [17](https://github.com/Electron100/butane/actions/runs/8494515035/job/23269791025?pr=232#step:16:18) others
   = note: required for `SqlVal` to implement `From<Whatsit>`
   = note: required for `Whatsit` to implement `Into<SqlVal>`
note: required by a bound in `FieldExpr`
  --> D:\a\butane\butane\butane_core\src\query\fieldexpr.rs:33:8
   |
31 | pub struct FieldExpr<T>
   |            --------- required by a bound in this struct
32 | where
33 |     T: Into<SqlVal>,
   |        ^^^^^^^^^^^^ required by this bound in `FieldExpr`
   = note: this error originates in the attribute macro `model` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0[27](https://github.com/Electron100/butane/actions/runs/8494515035/job/23269791025?pr=232#step:16:28)7`.
error: could not compile `butane` (test "custom_enum_derived") due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
jayvdb commented 2 months ago

Occurring still, this time in basic

failed to read types "/home/runner/work/butane/butane/butane/.butane/migrations/current/types.json"
unable to save type (De)serialization error trailing characters at line 2 column 1
error: unable to save type
Error:   --> butane/tests/basic.rs:11:1
   |
11 | #[butane_type]
   | ^^^^^^^^^^^^^^
   |
   = note: this error originates in the attribute macro `butane_type` (in Nightly builds, run with -Z macro-backtrace for more info)

failed to read types "/home/runner/work/butane/butane/butane/.butane/migrations/current/types.json"
error[E0412]: cannot find type `Whatsit` in this scope
Error:   --> butane/tests/basic.rs:[22](https://github.com/Electron100/butane/actions/runs/8766992655/job/24059745139?pr=252#step:18:23):10
   |
22 |     baz: Whatsit,
   |          ^^^^^^^ not found in this scope

error: custom attribute panicked
Error:   --> butane/tests/common/blog.rs:86:1
...