question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incorrect serialization in production build

See original GitHub issue

Sample code

@Serializable()
export class ApiPaginationFilters {

  public page: number = 1;

  @JsonProperty()
  public offset: number;

  constructor(
    @JsonProperty()
    public limit: number,
  ) {
  }

  public nextPage(): void {
    this.setPage(this.page + 1);
  }

  public setPage(page: number): void {
    this.page = page;
    this.offset = (this.page - 1) * this.limit;
  }

  public previousPage(): void {
    if (this.page === 1) {
      return;
    }
    this.setPage(this.page + 1);
  }

}

@Serializable()
export class EosagoArchiveParams extends ApiPaginationFilters {

  @JsonProperty()
  public state: string;

  @JsonProperty({
    name: 'start_date',
  })
  public startDate: string;

  @JsonProperty({
    name: 'end_date',
  })
  public endDate: string;
}

const params = new EosagoArchiveParams(5);
console.log(params);
console.log(serialize(params));

And this code has different console output in develop and production build of angular app.

Dev: dev-chrome

Prod: prod-chrome

Serialize instance of ApiPaginationFilters leads to same result

Declaring properties like this

@Serializable()
export class ApiPaginationFilters {

  public page: number = 1;

  @JsonProperty()
  public offset: number;

  @JsonProperty()
  public limit: number;

  constructor(
    limit: number,
  ) {
    this.limit = limit;
  }

  /* ... */

}

leads to same result too.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
AndreyWVcommented, Jul 2, 2021

It works correctly now. Thanks! 😃

1reaction
GillianPerardcommented, Jul 2, 2021

I published the version 3.4.2.

Tell me if it works for you 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Inherited serializable fields lead to incorrect serialization order
This Issue is producable with kotlin >=1.3.20. Consider the following scenario with a base class: import kotlinx.serialization.
Read more >
InvalidCastException when serializing and deserializing
I solved this problem by enumerating the loaded assemblies in my appdomain, looking for a matching assembly name (parsed from my AssemblyQualifiedName). Once ......
Read more >
Machine Learning Model Serialization - Christopher Flynn, PhD
The most common method is to serialize the model using some particular format after training, and deserialize that model in the production ......
Read more >
Rust serialization: What's ready for production today?
In this guide, we'll compare 12 serialization crates in various states of production-readiness, considering API usability and performance.
Read more >
Oracle Calls Java Serialization 'A Horrible Mistake ... - Slashdot
Java object serialization bypasses all validation, permitting an attacker to construct a malformed object. Exactly how that would cause a ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found