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

ERROR "Cannot read properties of undefined (reading 'currentPage')" - after build of new code #323

Closed
bpawnzZ opened this issue Jul 28, 2024 · 8 comments

Comments

@bpawnzZ
Copy link

bpawnzZ commented Jul 28, 2024

I posted this last week and received no response but it was marked closed???. Just did a git pull of most recent code and still same issue.. Can u help me out with why this going on or how i can fix?? Thank you

Hello all. To start with I am using 'docker-compose.postgres.yml'. Been using Teldrive for 6ish months and love it. I have a build that is prolly 3 weeks old and works as usual with no problem. Bur for past 2 weeks if i build with updated code from github I get the error below. However if I rollback to previous build it is no problem. Why is this happening and did something break or change?? And if something did change how can i fix it on my end.
350621830-24549ad1-b015-4be2-b106-99c3ad827383
I can connect to DB so I really dont know why it is doing this.
350625711-7bb3c98d-1ce5-4e9f-9bb8-7fe47756241c

version: "3.8"

services:
  server:
    image: bpawnzz/teldrivecustom:v1
    restart: always
    hostname: teldrive
    container_name: teldrive
    volumes:
      - ./session.db:/session.db:rw
      - ./config.toml:/config.toml
    ports:
      - 1234:8080
    depends_on:
      db:
        condition: service_healthy
    dns:
      - 1.1.1.1

  db:
    image: groonga/pgroonga
    container_name: teldrive_db
    hostname: postgresTeldrive
    restart: always
    environment:
      - POSTGRES_USER=teldrive
      - POSTGRES_PASSWORD=secret
    volumes:
      - ./postgres_data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD", "pg_isready", "-U", "teldrive"]
      interval: 10s
      start_period: 30s
    dns:
      - 1.1.1.1
@bpawnzZ bpawnzZ changed the title ERROR "Cannot read properties of undefined (reading 'currentPage')" - after moving to new host ERROR "Cannot read properties of undefined (reading 'currentPage')" - after build of new code Jul 28, 2024
@SingingDalong
Copy link

SingingDalong commented Jul 28, 2024

As long as you have a DB, you won't lose any data. Test it on other OSs like Windows. Alternatively, you can also test it with Oracle's free VPS. In my experience, it also works well on Oracle's free VPS.
I'm installing PostgreSQL server on the first instance of Oracle and using Teldrive on the second instance.

@bpawnzZ
Copy link
Author

bpawnzZ commented Jul 29, 2024

As long as you have a DB, you won't lose any data. Test it on other OSs like Windows. Alternatively, you can also test it with Oracle's free VPS. In my experience, it also works well on Oracle's free VPS. I'm installing PostgreSQL server on the first instance of Oracle and using Teldrive on the second instance.

I'm on a VPS running debian and zfs filesystm.. and I have arch on my desktop and laptop.. same issue on all of them.. without a doubt i am not going to windows. Do you know of anything that changed in the database structure recently or something. and i will export/import and manipulate the data. Just doesn't make sense how I have run this flawlessly for months and now all of the sudden there is a breaking change.

I can rollback to any of the previous versions and no issue. Something had to have changed in the database structure.

And Fyi it is not resource constraints on vps or anything. I have a fairly stout virtual server resource wise.

I currently have ovr 8k files on Teldrive. I honestly understand this project I feel like pretty well. Just frustrating I cant get a str8 answer from the devs

@vavtnen
Copy link

vavtnen commented Jul 30, 2024

Try these steps.

  1. Start with a new db.
  2. Log in to make sure everything work.
  3. Truncate the 'files' table in your new db.
  4. Export 'files' table from your old db.
  5. Import it to your new db.

@bpawnzZ
Copy link
Author

bpawnzZ commented Aug 3, 2024

Try these steps.

  1. Start with a new db.
  2. Log in to make sure everything work.
  3. Truncate the 'files' table in your new db.
  4. Export 'files' table from your old db.
  5. Import it to your new db.

Just saw this.. Will deff give it a go. Thank you for the response!

@bpawnzZ
Copy link
Author

bpawnzZ commented Aug 9, 2024

Try these steps.

  1. Start with a new db.
  2. Log in to make sure everything work.
  3. Truncate the 'files' table in your new db.
  4. Export 'files' table from your old db.
  5. Import it to your new db.

So i did what you said to a t. and i am now receiving this error in my database logs. And the teldrive interface/web frontend is blank where the files would go. FYI still have my original DB and working on older versions of this software.

09/08/2024 04:58 AM	ERROR	ERROR: function teldrive.get_file_from_path(unknown, unknown, unknown) does not exist (SQLSTATE 42883)
09/08/2024 04:58 AM	INFO		{"status": 500, "method": "GET", "path": "/api/files", "query": "page=1&limit=500&order=asc&sort=name&path=%2F", "ip": "169.69.0.1", "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36", "latency": 0.008012637, "time": "2024-08-09T04:58:29Z"}
09/08/2024 04:58 AM	ERROR	[DB] github.com/divyam234/teldrive/pkg/services/file.go:327 ERROR: function teldrive.get_file_from_path(unknown, unknown, unknown) does not exist (SQLSTATE 42883)
[1.582ms] [rows:-] WITH "ranked_scores" AS (SELECT "name",count(*) OVER () as total,ROW_NUMBER() OVER (ORDER BY name ASC) AS rank FROM "teldrive"."files" WHERE user_id = 942624240 AND status = 'active' AND parent_id in (SELECT id FROM teldrive.get_file_from_path('/', 942624240, true))) SELECT *,(select total from ranked_scores limit 1) as total FROM "teldrive"."files" WHERE name >= (SELECT name FROM ranked_scores WHERE rank = 1) AND (user_id = 942624240 AND status = 'active' AND parent_id in (SELECT id FROM teldrive.get_file_from_path('/', 942624240, true))) ORDER BY "name" LIMIT 500
09/08/2024 04:58 AM	ERROR	ERROR: function teldrive.get_file_from_path(unknown, unknown, unknown) does not exist (SQLSTATE 42883)
09/08/2024 04:58 AM	INFO		{"status": 500, "method": "GET", "path": "/api/files", "query": "page=1&limit=500&order=asc&sort=name&path=%2F", "ip": "169.69.0.1", "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36", "latency": 0.002080888, "time": "2024-08-09T04:58:38Z"}
09/08/2024 04:58 AM	ERROR	[DB] github.com/divyam234/teldrive/pkg/services/file.go:327 ERROR: function teldrive.get_file_from_path(unknown, unknown, unknown) does not exist (SQLSTATE 42883)
[1.422ms] [rows:-] WITH "ranked_scores" AS (SELECT "name",count(*) OVER () as total,ROW_NUMBER() OVER (ORDER BY name ASC) AS rank FROM "teldrive"."files" WHERE user_id = 942624240 AND status = 'active' AND parent_id in (SELECT id FROM teldrive.get_file_from_path('/', 942624240, true))) SELECT *,(select total from ranked_scores limit 1) as total FROM "teldrive"."files" WHERE name >= (SELECT name FROM ranked_scores WHERE rank = 1) AND (user_id = 942624240 AND status = 'active' AND parent_id in (SELECT id FROM teldrive.get_file_from_path('/', 942624240, true))) ORDER BY "name" LIMIT 500
09/08/2024 04:58 AM	ERROR	ERROR: function teldrive.get_file_from_path(unknown, unknown, unknown) does not exist (SQLSTATE 42883)
09/08/2024 04:58 AM	INFO		{"status": 500, "method": "GET", "path": "/api/files", "query": "page=1&limit=500&order=asc&sort=name&path=%2F", "ip": "169.69.0.1", "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36", "latency": 0.001759131, "time": "2024-08-09T04:58:54Z"}
09/08/2024 04:59 AM	ERROR	[DB] github.com/divyam234/teldrive/pkg/services/file.go:327 ERROR: function teldrive.get_file_from_path(unknown, unknown, unknown) does not exist (SQLSTATE 42883)
[2.030ms] [rows:-] WITH "ranked_scores" AS (SELECT "name",count(*) OVER () as total,ROW_NUMBER() OVER (ORDER BY name ASC) AS rank FROM "teldrive"."files" WHERE user_id = 942624240 AND status = 'active' AND parent_id in (SELECT id FROM teldrive.get_file_from_path('/', 942624240, true))) SELECT *,(select total from ranked_scores limit 1) as total FROM "teldrive"."files" WHERE name >= (SELECT name FROM ranked_scores WHERE rank = 1) AND (user_id = 942624240 AND status = 'active' AND parent_id in (SELECT id FROM teldrive.get_file_from_path('/', 942624240, true))) ORDER BY "name" LIMIT 500
09/08/2024 04:59 AM	ERROR	ERROR: function teldrive.get_file_from_path(unknown, unknown, unknown) does not exist (SQLSTATE 42883)
09/08/2024 04:59 AM	INFO		{"status": 500, "method": "GET", "path": "/api/files", "query": "page=1&limit=500&order=asc&sort=name&path=%2F", "ip": "169.69.0.1", "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36", "latency": 0.002337977, "time": "2024-08-09T04:59:24Z"}

Do you have any suggestions??

@vavtnen
Copy link

vavtnen commented Aug 12, 2024

That error meant that you are using old db with newer version of teldrive. Which version are you able to run?

@bpawnzZ
Copy link
Author

bpawnzZ commented Aug 14, 2024

For anyone interested I was able to successfully migrate my db with the following script.. Your welcome ;)

I didn't loose a thing. 100% successful migration

import psycopg2
from psycopg2.extras import execute_values, Json
import json

# Source database connection details
SRC_DB = {
    'host': '127.0.0.1',
    'port': '5431',
    'database': 'defaultdb',
    'user': 'teldrive',
    'password': 'secret'
}

# Destination database connection details
DEST_DB = {
    'host': '127.0.0.1',
    'port': '5432',
    'database': 'teldrive',
    'user': 'teldrive',
    'password': 'secret'
}

# List of tables to transfer (in order, considering foreign key dependencies)
TABLES = [
    'teldrive.users',
    'teldrive.channels',
    'teldrive.bots',
    'teldrive.uploads',
    'teldrive.sessions',
    'teldrive.files',
    'public.goose_db_version'
]

def adapt_dict(python_dict):
    return Json(python_dict)

psycopg2.extensions.register_adapter(dict, adapt_dict)

def connect_db(db_config):
    return psycopg2.connect(**db_config)

def get_table_data(cursor, table):
    cursor.execute(f"SELECT * FROM {table}")
    return cursor.fetchall()

def get_column_names(cursor, table):
    cursor.execute(f"""
        SELECT column_name 
        FROM information_schema.columns 
        WHERE table_schema = %s AND table_name = %s 
        ORDER BY ordinal_position
    """, table.split('.'))
    return [col[0] for col in cursor.fetchall()]

def transfer_table(src_cursor, dest_cursor, table):
    print(f"Transferring data for table: {table}")
    
    # Get column names and types
    src_cursor.execute(f"""
        SELECT column_name, data_type 
        FROM information_schema.columns 
        WHERE table_schema = %s AND table_name = %s 
        ORDER BY ordinal_position
    """, table.split('.'))
    columns_info = src_cursor.fetchall()
    columns = [col[0] for col in columns_info]
    column_str = ', '.join(columns)
    
    # Fetch data from source
    src_cursor.execute(f"SELECT {column_str} FROM {table}")
    data = src_cursor.fetchall()
    
    if not data:
        print(f"No data to transfer for table: {table}")
        return
    
    # Prepare the INSERT statement with type casting for JSONB and numbered placeholders
    insert_columns = []
    for i, (col, data_type) in enumerate(columns_info, start=1):
        if data_type == 'jsonb':
            insert_columns.append(f"CAST(%s AS JSONB)")
        else:
            insert_columns.append(f"%s")
    insert_column_str = ', '.join(insert_columns)
    
    insert_stmt = f"INSERT INTO {table} ({column_str}) VALUES ({insert_column_str}) ON CONFLICT DO NOTHING"
    
    # Convert any JSON strings to dicts for proper handling
    processed_data = []
    for row in data:
        processed_row = list(row)
        for i, (col, data_type) in enumerate(columns_info):
            if data_type == 'jsonb':
                if isinstance(processed_row[i], str):
                    try:
                        processed_row[i] = json.dumps(json.loads(processed_row[i]))
                    except json.JSONDecodeError:
                        processed_row[i] = json.dumps({})  # Default to empty JSON object if parsing fails
                elif processed_row[i] is None:
                    processed_row[i] = json.dumps({})  # Default to empty JSON object if None
                else:
                    processed_row[i] = json.dumps(processed_row[i])  # Ensure it's a JSON string
        processed_data.append(tuple(processed_row))
    
    # Execute the INSERT
    dest_cursor.executemany(insert_stmt, processed_data)
    
    print(f"Transferred {len(data)} rows for table: {table}")

def main():
    src_conn = connect_db(SRC_DB)
    dest_conn = connect_db(DEST_DB)
    
    src_cursor = src_conn.cursor()
    dest_cursor = dest_conn.cursor()
    
    try:
        for table in TABLES:
            transfer_table(src_cursor, dest_cursor, table)
            dest_conn.commit()
        
        print("Data transfer completed successfully!")
    
    except Exception as e:
        print(f"An error occurred: {e}")
        dest_conn.rollback()
    
    finally:
        src_cursor.close()
        dest_cursor.close()
        src_conn.close()
        dest_conn.close()

if __name__ == "__main__":
    main()
 

@bpawnzZ
Copy link
Author

bpawnzZ commented Aug 14, 2024

That error meant that you are using old db with newer version of teldrive. Which version are you able to run?

I'm officially running newest version and successfully migrated my db. I just posted script in thread.

@bpawnzZ bpawnzZ closed this as completed Aug 14, 2024
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

No branches or pull requests

3 participants